Char to int

First possibility

char c;
//some input to c
int number;
number = c -'0';

Second possibility

char c[2];
c[1]=0;
//some input to c
number = atoi(c);
programming/c-cpp/chartoint.txt · Last modified: 2018-06-21 19:48 (external edit)
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0