What's the escape sequence for blanks in C?
You mean "blanks" like in "a b"
? That's a space: ' '
.
Here's a list of escape sequences for reference.
If you want to check if a character is whitespace, you can use the isspace()
function from <ctype.h>
. In the default C locale, it checks for space, tab, form feed, newline, carriage return and vertical tab.
Space is simply ' '
, in hex it is stored as 20, which is the integer equivalent of 32. For example:
if (a == ' ')
Checks for integer 32. Likewise:
if (a == '\n')
Checks for integer 10 since \n
is 0A
in hex, which is the integer 10.
Here are the rest of the most common escape sequences and their hex and integer counterparts:
code: │ name: │Hex to integer:
──────│────────────────────────│──────────────
\n │ # Newline │ Hex 0A = 10
\t │ # Horizontal Tab │ Hex 09 = 9
\v │ # Vertical Tab │ Hex 0B = 11
\b │ # Backspace │ Hex 08 = 8
\r │ # Carriage Return │ Hex 0D = 13
\f │ # Form feed │ Hex 0C = 12
\a │ # Audible Alert (bell)│ Hex 07 = 7
\\ │ # Backslash │ Hex 5C = 92
\? │ # Question mark │ Hex 3F = 63
\' │ # Single quote │ Hex 27 = 39
\" │ # Double quote │ Hex 22 = 34
' ' │ # Space/Blank │ Hex 20 = 32