function joe

Dependencies:   mbed

Revision:
0:6e23fd4c8843
diff -r 000000000000 -r 6e23fd4c8843 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Dec 02 07:37:18 2016 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+ 
+Serial pc(D1,D0);
+
+//int char2posit(char cha);
+//char posit2char(int posit);
+
+char posit2char(int posit)
+{
+    int as = posit+48;
+    char ch = as;
+    return ch ;
+}
+
+int char2posit(char cha)
+{
+    int as = cha;
+    as = as-48;
+    return as;
+}
+
+int main()
+{
+    int i = 53;
+    char th='h';
+    while(1){
+        
+        pc.printf("****ch = %c\n",posit2char(i));
+        pc.printf("****int = %d\n\n",char2posit(posit2char(i)));
+        wait(1);
+        }
+}
+
+
+
+/*
+  char c;
+    pc.printf("Enter a character: ");
+
+    // Reads character input from the user
+    pc.scanf("%c", &c);  
+    
+    // %d displays the integer value of a character
+    // %c displays the actual character
+    pc.printf("ASCII value of %c = %d\n\n", c, c);
+   
+
+    
+    //int myInt = 48+i;
+//
+//    //scanf("%d", myInt);
+//    char ch = myInt;
+//
+//    pc.printf("%c = %d\n",ch,myInt);
+//    i++;
+//    wait(0.75);
+*/