Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
C syntax
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Backslash escapes==== {{main|Escape sequences in C}} Because certain characters cannot be part of a literal string expression directly, they are instead identified by an escape sequence starting with a backslash ({{code|\}}). For example, the backslashes in {{code|"This string contains \"double quotes\"."}} indicate (to the compiler) that the inner pair of quotes are intended as an actual part of the string, rather than the default reading as a delimiter (endpoint) of the string itself. Backslashes may be used to enter various control characters, etc., into a string: {| class="wikitable" ! align="left" |Escape ! align="left" |Meaning |- | {{code|\\}} || Literal backslash |- | {{code|\"}} || Double quote |- | {{code|\'}} || Single quote |- | {{code|\n}} || Newline (line feed) |- | {{code|\r}} || Carriage return |- | {{code|\b}} || Backspace |- | {{code|\t}} || Horizontal tab |- | {{code|\f}} || Form feed |- | {{code|\a}} || Alert (bell) |- | {{code|\v}} || Vertical tab |- | {{code|\?}} || Question mark (used to escape [[C trigraph|trigraphs]], obsolete feature dropped in C23) |- | <code>\''OOO''</code> || Character with octal value ''OOO'' (where ''OOO'' is 1-3 octal digits, '0'-'7') |- | <code>\x''hh''</code> || Character with hexadecimal value ''hh'' (where ''hh'' is 1 or more hex digits, '0'-'9','A'-'F','a'-'f') |- | <code>\u''hhhh''</code> || [[Unicode]] [[code point]] below 10000 hexadecimal (added in C99) |- | <code>\U''hhhhhhhh''</code> || Unicode code point where ''hhhhhhhh'' is eight hexadecimal digits (added in C99) |} The use of other backslash escapes is not defined by the C standard, although compiler vendors often provide additional escape codes as language extensions. One of these is the escape sequence <code>\e</code> for the [[escape character]] with ASCII hex value 1B which was not added to the C standard due to lacking representation in other [[character set]]s (such as [[EBCDIC]]). It is available in [[GNU Compiler Collection|GCC]], [[clang]] and [[Tiny C Compiler|tcc]]. Note that [[printf format string]]s use {{code|%%}} to represent literal {{code|%}} character; there is no {{code|\%}} escape sequence in standard C.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)