B
Ben
Hi all,
enum Colors defined as:
enum Colors{Red, Blue, Green};
I have a text file "colors.txt" with the following content, one per
line:
Red
Blue
Green.
My read() function is supposed to read an enumerated variable from
"colors.txt" file and to return a variable of type Colors. I'm not
sure how to do it.
My effort:
Colors read (ifstream inFile) {
char buffer[256];
while (!inFile.eof()) { //perhaps i don't even need this while
loop???
inFile.getline (buffer,100);
}
return (Colors(buffer)); // IT'S WRONG HERE!! ANY SUGGESTIONS??
}
Can anyone please show me the way..
Thanx for your time!
Ben
enum Colors defined as:
enum Colors{Red, Blue, Green};
I have a text file "colors.txt" with the following content, one per
line:
Red
Blue
Green.
My read() function is supposed to read an enumerated variable from
"colors.txt" file and to return a variable of type Colors. I'm not
sure how to do it.
My effort:
Colors read (ifstream inFile) {
char buffer[256];
while (!inFile.eof()) { //perhaps i don't even need this while
loop???
inFile.getline (buffer,100);
}
return (Colors(buffer)); // IT'S WRONG HERE!! ANY SUGGESTIONS??
}
Can anyone please show me the way..
Thanx for your time!
Ben