Click here to Skip to main content
11,577,258 members (59,957 online)
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 19:14pm
Edited 17-Sep-12 23:36pm
Malli_S27K
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 DamithSL 155
1 Afzaal Ahmad Zeeshan 125
2 OriginalGriff 115
3 Richard MacCutchan 100
4 Abhinav S 90
0 OriginalGriff 820
1 Sergey Alexandrovich Kryukov 676
2 Abhinav S 528
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 375


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 18 Sep 2012
Copyright © CodeProject, 1999-2015
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