By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,813 Members | 2,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,813 IT Pros & Developers. It's quick & easy.

Convert character code to Letter

P: 1
Is there Function in visual c++ to get the character when is is given the character code (or Ascii value)


when is is given 65 it should give "A" letter, like in VB6
Jun 16 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
char variables are just 8-bi integers. int variables are usually 32-bit integers. You can convert freely just by assignment or initialization:

Expand|Select|Wrap|Line Numbers
  1. int  data = 65;
  2. int  data 1 = 'A';  //same as above line 'A' is 65.
  3. char c = data;    //c has 65
  4. cout << c;     //you see A
  5. cout << data; //you see 65
That means you don't need a function to do this.

On the display, you see 65 or A depending upon the type of variable on the right side of the << operator. If it is a char, an operator<< function is called that takes a char argument. This function will show you A. If it is an int, another operator<< function is called that takes an int argunment. This function will show you 65.

The compiler will give no warning if the value in your int is too big for your char.
Jun 17 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.