char to int

Dependencies:   mbed

main.cpp

Committer:
DnPlas
Date:
2014-10-16
Revision:
0:7954138db952

File content as of revision 0:7954138db952:

/*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);
    }
}