Hi,
Can any one please tell me what is the best way to convert a char to an int. I can not seem to find any build in function to do the job. Thanks in advance.
Printable View
Hi,
Can any one please tell me what is the best way to convert a char to an int. I can not seem to find any build in function to do the job. Thanks in advance.
Use atoi() from <stdlib.h>.
char Words[]="123";
int Number;
Number = atoi(Words);
Jason
atoi() will return 0 if any character is not a digit
for a single char you can do it like this:
char letter = 'a';
int number = (int)letter;