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.
This is a discussion on char to int within the C++ Programming forums, part of the General Programming Boards category; Hi, Can any one please tell me what is the best way to convert a char to an int. I ...
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;