• Advertisement
Sign in to follow this  

Chars literals?

This topic is 4149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Random comments:
\n = Line Feed
\r = Carrige Return
\t = Tab
\0 = Null terminator

Those are the ones you're most likely to come across.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Those are the ones you're most likely to come across.


As well as the obvious \\, \' and \".


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement