Click here to Skip to main content
12,253,908 members (59,338 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++
Hi my friends .
pleas give me a solution about converting int to char and convert char to int in win32 project
Thank you .
Posted 17-Sep-12 19:14pm
Edited 17-Sep-12 23:36pm
Malli_S28.2K
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Аslam Iqbal 18-Sep-12 2:06am
   
nice
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Give a example.
char ch = '0';
int n = ch - 48;
Than value of n is 0.
48 is the distance in ASCII table.
  Permalink  
Comments
Richard MacCutchan 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.
Richard MacCutchan 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.
Richard MacCutchan 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?
Joneeky 19-Sep-12 1:01am
   
OK, I have learnt.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 18 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100