11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Special charactersChapter 2: Declaring Variables Constantly 35You can store any printable character you want in a char or string variable.You can also store a set of non-printable characters that is used ascharacter constants. See Table 2-2 for a description of these important nonprintablecharacters.Table 2-2Special CharactersCharacter ConstantAction‘\n’newline‘\t’tab‘\0’ null‘\\’ backslashYou have already seen the newline character at the end of strings. This characterbreaks a string and puts the parts on separate lines. A newline charactermay appear anywhere within a string. For example,“This is line 1\nThis is line 2”appears on the output asThis is line 1This is line 2Similarly, the \t tab character moves output to the next tab position. (Thisposition can vary, depending on the type of computer you’re using to run theprogram.) Because the backslash character is used to signify special characters,a character pair for the backslash itself is required. The character pair\\ represents the backslash.C++ collision with file namesWindows uses the backslash character to separatefolder names in the path to a file. (This isa remnant of MS-DOS that Windows has notbeen able to shake.) Thus, Root\FolderA\File represents File within FolderA, whichis a subdirectory of Root.Unfortunately, MS-DOS’s use of backslash con­flicts with the use of backslash to indicate anescape character in C++. The character \\ is abackslash in C++. The MS-DOS path Root\FolderA\File is represented in C++ string asRoot\\FolderA\\File.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!