Computing.Net > Forums > Programming > converting ascii int value to char

converting ascii int value to char

Reply to Message Icon

Original Message
Name: Warren
Date: September 18, 2002 at 21:40:59 Pacific
Subject: converting ascii int value to char
OS: Win95 OSR-2
CPU/Ram: Intel 200 MMX 64 MB RAM
Comment:

I'm using DJGPP and have set up the following code to read from the keyboard and then print to the screen:

int _c = getch();//from the keyboard
putch(_c); //to the screen
cout << _c;// outputs _c

When I do this it prints the correct character to the screen. However _c is output as the int value. I wish to concatenate the chars thus I need to covert the int values to chars to do this. How do I do this?


Report Offensive Message For Removal


Response Number 1
Name: Tom
Date: September 19, 2002 at 00:30:49 Pacific
Reply: (edit)

You cast them:
cout << (char) _c;


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: converting ascii int value to char 

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes Today.
Discuss in The Lounge