create a pointer and use increament operator to read the string. This should be maintained in a loop till the end of string. And for every next character make a check using if(*ptr == ' ') then your counter, which counts the number of words, should not increase.
This is pretty simple. Just take your string (which depending on how your using strings, will be a char* or an std::string), and iterate through each char until you reach the '\n' new line character.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.