Counting Whitespace

Hey guys, I've been looking around on the internet trying to figure out how to count whitespaces entered into a console. The only thing I'm coming up with is how to do it while reading from a file.
I also looked at some links on here including this one.
http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/


I thought if I did something like what I have below that it would work, but it didn't. Granted the int main() is missing, I'm more interested in other ideas that would make this work.

1
2
3
4
5
6
7
8
9
10
11
12
int whitespace = 0;
int large = 10;
int small = 0;

while(small != large)
{

    small = small + 1;
    cout << " ";
    cout << small;
    whitespace = whitespace + 1;
}
Use cin.get(char) to look at each character, and isspace(char) to check if it's whitespace.
so I could use something like

cin.get()
if (isspace(" ")
{
whitespace = whitespace + 1;
}
Topic archived. No new replies allowed.