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 wa
No special escape sequence is required: you can just type the space directly:
if (char_i_want_to_test == ' ') {
// Do something because it is space
}
In ASCII, space is code 32, so you could specify space by '\x20'
or even 32
, but you really shouldn't do that.
Aside: the word "whitespace" is a catch all for space, tab, newline, and all of that. When you're referring specifically to the ordinary space character, you shouldn't use the term.