Print single letter words from txt document

In my assignment I'm opening up a txt doc with thousands of words (some only 1 character), I want my program to print only those 1 character words. I thought i could do something like this but i can't get the condition right.. any help is greatly appreciated.

1
2
3
4
5
6
7
8
9
ifstream inStream;
string word;

  while (inStream) {
    inStream >> word;

    if (sizeof(word) = 1) {
    cout << word << endl;
		}


i know the problem is that word is a string and 1 is an int but idk how i should proceed
if (sizeof(word) = 1)
should be
if (word.size() == 1)
TheIdeasMan wrote:
Just a note for the future :+)

There also shouldn't be 2 topics about essentially the same subject. There is a risk that the same things will be said in both, possibly making it a time waster for those who reply.


http://www.cplusplus.com/forum/beginner/194209/#msg934051
Topic archived. No new replies allowed.