• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

C++ Question.

Status
Not open for further replies.
How would I go about converting an escape sequence character into it's ASCII code? I have to convert it to hex/octal as well, but I can figure those out once I learn how to get the ASCII code. HELP.
 

Slo

Member
I'm not sure I understand the problem. You have the task of converting ASCII characters into Hex and octal, and you're having problems with characters with escape sequences in them? Is that correct? Are you parsing the tokens from a file?
 
"You have the task of converting ASCII characters into Hex and octal, and you're having problems with characters with escape sequences in them? Is that correct?"

Well, it's more along the lines of converting the escape sequence into its actual ASCII code and that number into hex and octal.

I'm only supposed to do the escape sequence characters, but yeah, that's pretty much it.

"Are you parsing the tokens from a file?"

No. It's supposed to be really simple. I show the escape sequence (The actual character), its name, and then its ASCII code, Hex, blah blah.
 
char escapeChar;
printf("%c %d %x %o\n",escapeChar,escapeChar,escapeChar,escapeChar);

With the name of the character between %c and %d, or something to that effect.
 
So, you're not writing a function, where escapeChar could be a parameter? Wierd. Where are you getting the escapeChar from? stdin? Are there any other limitations?
 
Status
Not open for further replies.
Top Bottom