Chars literals?

Started by
3 comments, last by Zahlman 17 years, 6 months ago
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.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Advertisement
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
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
Random comments:
\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.

This topic is closed to new replies.

Advertisement