


When a newline character (equivalent to pressing the RETURN key) immediately follows the backslash, the compiler ignores the backslash and the newline character and treats the next line as part of the previous line. You can also use the backslash ( \) as a continuation character. For instance, the vertical tab and form feed escape sequences ( \v and \f) do not affect screen output, but they do perform appropriate printer operations. Some escape sequences are device-specific. For example, the ESC character ( \033) is often used as the first character of a control command for a terminal or printer. For example, \c is treated as an c.Įscape sequences allow you to send nongraphic control characters to a display device. If a backslash precedes a character that does not appear in the table, the compiler handles the undefined character as the character itself. Unicode character in hexadecimal notation if this escape sequence is used in a wide-character constant or a Unicode string literal.įor example, WCHAR f = L'\x4e00' or WCHAR b = L"The Chinese character for one is \x4e00". Note that the question mark preceded by a backslash ( \?) specifies a literal question mark in cases where the character sequence would be misinterpreted as a trigraph. An escape sequence contains a backslash () symbol followed by one of the escape sequence characters or an octal or hexadecimal number. The following table lists the ANSI escape sequences and what they represent. They are also used to provide literal representations of nonprinting characters and characters that usually have special meanings, such as the double quotation mark ( "). An escape sequence is regarded as a single character and is therefore valid as a character constant.Įscape sequences are typically used to specify actions such as carriage returns and tab movements on terminals and printers. Inserts a backslash character in the text at this point.Character combinations consisting of a backslash ( \) followed by a letter or by a combination of digits are called "escape sequences." To represent a newline character, single quotation mark, or certain other characters in a character constant, you must use escape sequences. Inserts a double quote character in the text at this point. The general format for an ANSI-compliant escape sequence is defined by ANSI X3.41 (equivalent to ECMA-35 or ISO/IEC 2022).: 13.1 The escape sequences consist only of bytes in the range 0x200x7F (all the non-control ASCII characters), and can be parsed without looking ahead. Inserts a single quote character in the text at this point.
#C language ansi escape sequences code
Inserts a form feed in the text at this point. It really seems like all other escape code sets have died out, and that ANSI codes (or ECMA-48 codes, or VT102 codes) have become the de-facto standard that the development community has settled on. Inserts a carriage return in the text at this point. Inserts a newline in the text at this point. Inserts a backspace in the text at this point. The following table lists the escape sequences available in C programming language − Sr.No The following statement will not convey any meaning in C programming and it will be assumed as an invalid statement − char ch = '\1' Here, character n has been preceded by a backslash (\), it has special meaning which is a new line but keep in mind that backslash (\) has special meaning with a few characters only. In the following statement is a valid character and it is called a new line character − char ch = ' When a character is preceded by a backslash (\), it is called an escape sequence and it has a special meaning to the compiler. Many programming languages support a concept called Escape Sequence.
