Click here to Skip to main content
16,021,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi my friends .
pleas give me a solution about converting int to char and convert char to int in win32 project
Thank you .
Posted
Updated 17-Sep-12 23:36pm
v3

 
Share this answer
 
Comments
Аslam Iqbal 18-Sep-12 2:06am    
nice
Give a example.
char ch = '0';
int n = ch - 48;
Than value of n is 0.
48 is the distance in ASCII table.
 
Share this answer
 
Comments
[no name] 18-Sep-12 10:24am    
Why not int n = ch - '0';, which is at least obvious?
Joneeky 18-Sep-12 10:30am    
Yes,You also can do this. But I am used to use 48.
[no name] 18-Sep-12 10:43am    
It's about readability, '0' means something useful to a new person looking at the code, 48 does not.
Joneeky 18-Sep-12 10:48am    
Okey,maybe you are right.
[no name] 18-Sep-12 11:55am    
Well think about it. In the first line of your example you represent the value of the zero character by '0', which is quite clear. In the next line you represent the exact same value by the integer 48, and it is not immediately obvious where that value comes from. Somewhat inconsistent don't you think?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900