Escape Sequences for Nonprintable Characters in C++
By: Stanley B.
Some characters are nonprintable. A nonprintable character is a character for which there is no visible image, such as backspace or a control character. Other characters have special meaning in the language, such as the single and double quotation marks, and the backslash. Nonprintable characters and special characters are written using an escape sequence. An escape sequence begins with a backslash. The language defines the following escape sequences:
newline |
\n |
horizontal tab |
\t |
vertical tab |
\v |
backspace |
\b |
carriage return |
\r |
formfeed |
\f |
alert (bell) |
\a |
backslash |
\\ |
question mark |
\? |
single quote |
\' |
double quote |
\" |
We can write any character as a generalized escape sequence of the form
\ooo
where ooo represents a sequence of as many as three octal digits. The value of the octal digits represents the numerical value of the character. The following examples are representations of literal constants using the ASCII character set:
\7 (bell) \12 (newline) \40 (blank) \0 (null) \062 ('2') \115 ('M')
The character represented by '\0' is often called a "null character," and has special significance, as we shall soon see.
We can also write a character using a hexadecimal escape sequence
\xddd
consisting of a backslash, an x, and one or more hexadecimal digits.
Archived Comments
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Calculating total based on the given quantity and price in C++
Sorting an array of Strings in C++
Matrix using nested for loops in C++
Compute the square root of the sum of the squares of an array in C++
Calculate average using Two-Dimensional Array in C++
Two-Dimensional Array Manipulation in C++
Compiling and Linking Multiple Source Files in C++
Escape Sequences for Nonprintable Characters in C++
Using the Built-in Arithmetic Types in C++