char to int

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
DnPlas
Date:
Thu Oct 16 01:41:32 2014 +0000
Commit message:
char to int

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 7954138db952 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 16 01:41:32 2014 +0000
@@ -0,0 +1,20 @@
+/*This program shows how to convert a char to an int value
+Daniela Plascencia October 15th, 2014*/
+
+//-------LIRARIES------
+#include "mbed.h"
+
+//-------I/O PINS------
+Serial pc(USBTX, USBRX);
+
+//------VARIABLES------
+char x[3] = {'1','2','3'};
+//--------MAIN--------
+int main()
+{
+    while(1) {
+            int y = atoi(x); //atoi function converts char to int values included within an array
+            pc.printf("Char value = %d\n", y);
+            wait(1);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 7954138db952 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 16 01:41:32 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file