View Single Post
  #2 (permalink)  
Old October 3rd, 2005, 03:00 AM
Alan-LB Alan-LB is offline
Authorized User
 
Join Date: Mar 2005
Posts: 58
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Alan-LB Send a message via Yahoo to Alan-LB
Default

Because 57 is the ASCII value for the character '9'

If you want to convert a character value for a number into an int you must subtract the value of the character zero ('0')

char x = 9; //Character '9' = ASCII 57
int b;

b = x - '0'; //That is '9' - '0' = 57 - 48 = 9

Alan


Reply With Quote