What is the symbol for whitespace in C?

后端 未结 7 2071
醉话见心
醉话见心 2020-12-13 08:50

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

相关标签:
7条回答
  • 2020-12-13 09:52

    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.

    0 讨论(0)
提交回复
热议问题