Chars literals?
How do you call the literals that symbol chars in CPP.
Such as '\n'
Also, what is the char who its numeric value is 9?
I have a .c file and I encountered a char with a numeric value of 9.
Thanks in advance.
They are called "escape characters".
According to http://www.lookuptables.com/ character 9 is a tab so it should be OK for use in source code.
EDIT: I suck at HTML
According to http://www.lookuptables.com/ character 9 is a tab so it should be OK for use in source code.
EDIT: I suck at HTML
Random comments:
\n = Line Feed
\r = Carrige Return
\t = Tab
\0 = Null terminator
Those are the ones you're most likely to come across.
\n = Line Feed
\r = Carrige Return
\t = Tab
\0 = Null terminator
Those are the ones you're most likely to come across.
Quote:Original post by Evil Steve
Those are the ones you're most likely to come across.
As well as the obvious \\, \' and \".
The \n itself (or \0, \t etc.) is called an "escape sequence".
The code construct {single quote} {specification of one character: either an escape sequence of some sort, or an actual single character} {single quote} is a "character literal".
ASCII character 9 is a tab. For reference. However, it's poor style to specify the character that way if it's intended to be interpreted as text; a 'char' value of 9 (as opposed to '\t') should indicate a *byte* value of 9, i.e. the numeric quantity 9, stored in one byte.
The code construct {single quote} {specification of one character: either an escape sequence of some sort, or an actual single character} {single quote} is a "character literal".
ASCII character 9 is a tab. For reference. However, it's poor style to specify the character that way if it's intended to be interpreted as text; a 'char' value of 9 (as opposed to '\t') should indicate a *byte* value of 9, i.e. the numeric quantity 9, stored in one byte.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement