Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the symbol for whitespace in C?

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?

like image 762
Cesar A Avatar asked May 04 '15 15:05

Cesar A


People also ask

What is whitespace character in C?

When parsing code, the C compiler ignores white-space characters unless you use them as separators or as components of character constants or string literals. Use white-space characters to make a program more readable. Note that the compiler also treats comments as white space.

Is whitespace a symbol?

When rendered, a whitespace character does not correspond to a visible mark, but typically does occupy an area on a page. For example, the common whitespace symbol U+0020 SPACE (also ASCII 32) represents a blank space punctuation character in text, used as a word divider in Western scripts.

Is whitespace a function in C?

C isspace() The isspace() function checks whether a character is a white-space character or not. If an argument (character) passed to the isspace() function is a white-space character, it returns non-zero integer. If not, it returns 0.

What is whitespace syntax?

Syntax. Commands are composed of sequences of spaces, tab stops and linefeeds. All other characters are ignored and thus can be used for comments. For example, tab-space-space-space performs arithmetic addition of the top two elements on the stack.


1 Answers

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

' '      space  '\t'     horizontal tab  '\n'     newline '\v'     vertical tab  '\f'     form 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 ' '.

like image 155
haccks Avatar answered Oct 12 '22 11:10

haccks