answersLogoWhite

0


Best Answer

Escape sequences are combination of characters which when used together form one single unit with a special meaning.Eg:

when a blackslash('\') and 'n' are written together like '\n', this represents a newline character.


For more escape sequences visit the related link.


User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

Escape Sequences are codes entered as part of data input (or being generated as part of generated output) which change the interpretation of the symbol that follows the escape code.

For example, a regular expression uses the period to indicate repetition of the previous symbol zero or more times. Thus, a regular expression of "a.b" means "there could be the letter a, or multiple letters a, or none at all, followed by a single letter b." However, escaping the period with an escape code changes the interpretation. Assuming the back slash is used as an escape code, the directive "a\.b" means "there shall be a single letter a, followed by a period, followed by a single letter b."

Many programming languages and tools provide a similar mechanism to address a similar issue, but the details, the use-case, the caveats and the choice of symbols used vary with each language. Many systems use a back slash for an escape code, but this choice is by no means binding.

This answer is:
User Avatar

User Avatar

Wiki User

6y ago

An escape sequence is a sequence of characters that are to be replaced by another character sequence. This is necessary because some characters have special meaning to the language compiler and therefore cannot be used as character literals. For example, the double quotation character (") is used to delimit literal strings, but if we want to include a double quotation mark in our string then we must use an escape sequence to tell the compiler that it is not to be treated as a delimiter. The escape sequence for a double-quote is ", and can be used as follows:

char str[] = ''The man said, "Hello world!"";

All escape sequences are prefixed with a backslash character which means the backslash itself has special meaning as character literal. So if we want to include a backslash in our string then we must use the double backslash escape sequence, \\, like so:

char str[] = ''c:\\temp\\file.tmp";

Other escape sequences are mostly used to represent special characters that have no simple representation on the keyboard, such as backspace and newline. The C++ standard defines the following escape sequences:

\' - single quote (ASCII character code 0x27)

" - double quote (ASCII character code 0x22)

\? - question mark (ASCII character code 0x3f)

\\ - backslash (ASCII character code 0x5c)

\a - audible bell (a system beep) (ASCII character code 0x07)

\b - backspace (ASCII character code 0x08)

\f - form feed (ASCII character code 0x0c)

\n - newline (ASCII character code 0x0a)

\r - carriage return (ASCII character code 0x0d)

\t - horizontal tab (ASCII character code 0x09)

\v - vertical tab (ASCII character code 0x0b)

\nnn - arbitrary octal value (byte nnn)

\Xnn - arbitrary hexadecimal value (byte nn)

\Unnnn - universal character code (code point U+nnnn)

\Unnnnnnnn - universal character code (code point U+nnnnnnnn)

Of the octal escape sequences, \0 is the most useful as this represents the null character (ASCII character code 0x00). Note that octal escape sequences have a limit if 3 digits, but will terminate at the first non-octal digit if encountered sooner.

Hexadecimal escape sequences have no length limit, but will terminate at the first non-hexadecimal digit. However, if a hexadecimal value exceeds the limit of the character width (such as char or wchar_t) the result is unspecified.

The single quote escape sequence is not usually required in strings, but it is required when used as a character literal because a single quote delimits all character literals:

char quot = '\'';

The question mark is seldom required unless a string contains a trigraph such as "??/". This trigraph is interpreted as meaning "" (the same as the "\" escape sequence) whereas "?\?/" would be interpreted as being the trigraph itself "??/".

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are escape sequences in c language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What escape sequence is not used in c language?

The third one.


What symbol is use to join strings?

Language dependent. In C, for example, there no string as such, but you can use function strcat to concatenate zero-terminated character-sequences.


How do you add sound in a c code?

you can use '\a' escape sequence in C language to hear a beep from your computer. usage: printf("\a"); you will hear a sound on embedding above line in a C program.


What called ' percent ' in C programming language?

Nothing, but the % symbol denotes the remainder operation, eg: 7%4==3. Plus it is used in format-sequences of printf, scanf, strftime, strptime...


Why c language has name c why not a?

C-language was derived from B-language.


Which HTML escape character sequences displays a space?

You can use " " (Without double quotes)


What is previous language of c language?

language before c language is pascal


What is C language what does it do?

C Language is First Step of Programming Language, Help for C Language you are show the correct answer


Why many programming language are case sensitive?

Case-sensitivity greatly increases the number of tokens used to represent the language. As an example, escape sequences typically use an escape character (such as '\') followed by a single letter to denote a token. This would mean there'd be a maximum of just 26 escape sequence tokens. By using a mixture of upper and lower case letters, you double the number of available tokens. In C++, the casing helps us distinguish between a built-in name (all lowercase), a user-defined name (a leading capital) and a macro symbol (all uppercase): return (a built-in name) Return (a user-defined name) RETURN (a macro symbol)


Can clones isolated from cDNA libraries contain promoter sequences?

C DNA library lack information about introns and regulatory sequences like promoter , enhancer etc.


What is transformers 3 going to be rated?

PG-13 For Intense Sequences Of Action And Brief Language


What is NEXT rated?

It is rated PG-13 for intense sequences of violent action and some language.