Monday, March 21, 2011

C++ white space delimiter?

I have a class function that takes an istream which will have letters representing the days of the week. I need to cut this with a white space delimiter. How do I do this as this is all I have?:

bool DaysOfWeek::input(istream& ins)
{
string input;
//HOW DO I PUT THE ins stream in here as I do not know the length of the stream coming in
// I tried ins.getline(input, 7, " "); but this does not seem to work
for(int i = 0; i< (signed)inputedDays.length(); i++)
{
if(tolower(inputedDays[i]) == 'm'){
M = true;
continue; }
if(tolower(inputedDays[i]) == 't'){
T = true;
continue; }
if(tolower(inputedDays[i]) == 'w'){
W = true;
continue; }
if(tolower(inputedDays[i]) == 'r'){
R = true;
continue; }
if(tolower(inputedDays[i]) == 'f'){
F = true;
continue; }
if(tolower(inputedDays[i]) == 's'){
S = true;
continue; }

}
}

Answer on C++ white space delimiter?

Do you have a book on c++ Object-oriented progamming in c++ by Robert Lafore.

Reference Arguments (179)
Passing Simple Data Types By Reference (181)
Passing Structures By Reference (183)