I am trying to find the number of words in a line via getline(istream,line,'\n') by counting white spaces. What I am using to count white spaces is this:
int pos = Line.find(' ',0);
while(pos != string::npos)
{
pos = Line.find(' ',pos);
nwords++;
cout << pos << endl;
}
Is what im doing with find() legal in regard to white spaces? When this loop is executed,
cout for pos = 6, which is where my first white space is, however I cannot get it to proceed....



LinkBack URL
About LinkBacks


