while loop

hi! i needed to know whether anyone knew how to code this so that it will skip over the white spaces in a file. mdefn is a string and it is reading from a file with a line of whitespaces. so basically what it is doing is just retaining the last word before the # sign which is my sign to end. I cannot use infile.getline() or any of the other file commands so i do not know how retain all the words in my string. any help would be appreciated. thanks!

istream& operator>> (istream& input, Citem &rhsitem)
{
input >> rhsitem.mword;
while (rhsitem.mdefn != "#")
input >> rhsitem.mdefn;
return input;
}

ostream& operator<< (ostream& output, const Citem& rhsitem)
{
output <<rhsitem.mword;
cout << " - " ;
while (rhsitem.mdefn != "#")
output <<rhsitem.mdefn;
return output;
}
[956 byte] By [kb8coolj] at [2007-11-20 11:20:37]
# 1 Re: while loop
What does your input look like that getline() will not work (using
'#' as the delimmiter instead of '\n') ?

istream& operator>> (istream& input, Citem &rhsitem)
{
getline(input,rhsitem.mdefn,'#');
return input;
}
Philip Nicoletti at 2007-11-9 1:25:27 >