How is '\t\t' a character?

So I accidentally entered '\t\t' hoping to get two tabs (I realize what I did wrong) Instead of getting an error for what I thought would be entering a string/multiple characters as a character, '\t\t' printed to the console as '2313'. Can someone explain how '\t\t' is a character and how through cout, is printed as '2313'? Thanks.
Would you kindly post code? Probably "\t\t" 's value was interpreted as int, but who knows what you were doing ;)
you accidently used single quotes like you would for 1 char
use double quotes when you have more than 1 character ;)

"\t\t"
Last edited on
The decimal value for the tab character is '9', in binary this is '1001' or more accurately '00001001' since we are evidently working with 8 bit characters. If you put the binary values down next to each other you get '0000100100001001' which in decimal is '2313'. I assume that this is displayed as an integer because there is no character corresponding to that value on the standard english ASCII chart. I honestly don't know if this is intended behavior, you get a warning from the compiler when you do it, but I can't remember reading anything that specifically addresses this kind of jack-assery.

EDIT: BLAST YOU NINJAS! Seriously though, OP already said that he knows what he did wrong. There is no need to browbeat an already realised mistake.
Last edited on
I honestly don't know if this is intended behavior
Those are mulicharacter literals and their type is int and their value is implementation defined.

So it is better to avoid them. It compiles because it is technically in standard, and gives warning because they are usually undesireable.
Last edited on
thanks, Computergeek01, that makes a lot of sense. I've just never seen anything like that before.
Topic archived. No new replies allowed.