What is the symbol for whitespace in C?

Cesar A picture Cesar A · May 4, 2015 · Viewed 221.4k times · Source

I am trying to figure out how to check if a character is equal to white-space in C. I know that tabs are '\t' and newlines are '\n', but I want to be able to check for just a regular normal space (from the space-bar) inside of an if statement.

Does anybody know what is the character for this?

Answer

haccks picture haccks · May 4, 2015

There is no particular symbol for whitespace. It is actually a set of some characters which are:

' '      space 
'\t'     horizontal tab 
'\n'     newline
'\v'     vertical tab 
'\f'     feed 
'\r'     carriage return    

Use isspace standard library function from ctype.h if you want to check for any of these white-spaces.

For just a space, use ' '.