Click here to Skip to main content
Rate this: bad
good
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 20:14pm
Edited 18-Sep-12 0:36am
Malli_S25.6K
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Аslam Iqbal at 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 at 18-Sep-12 10:24am
   
Why not int n = ch - '0';, which is at least obvious?
Joneeky at 18-Sep-12 10:30am
   
Yes,You also can do this. But I am used to use 48.
Richard MacCutchan at 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 at 18-Sep-12 10:48am
   
Okey,maybe you are right.
Richard MacCutchan at 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 at 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
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,192
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 18 Sep 2012
Copyright © CodeProject, 1999-2014
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