Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if string.at(i) is a whitespace C++

I want to check if a char (string.at(i)) is whitespace in C++. How can I do this easily?

I got this code example, and I was thinking to change the _____ with something, but don't know what. I've tried with ' ', but that didn't work.

for(int i = 0; i < string.length(); i++)
{
    if(string.at(i) == _________)
    {
        //do something
    }
}
like image 964
user709712 Avatar asked Apr 16 '11 22:04

user709712


1 Answers

#include <cctype>

if (isspace(string.at(i)))
like image 62
dan04 Avatar answered Oct 01 '22 17:10

dan04