-
MultiLine I/O
How do I get multiple lines to be stored in my one string if I don't know how many lines there are? Here is my current code... but I know the != EOF part is wrong.
Code:
try {
ifstream b_file(fileName.c_str());
while(c != EOF) {
getline(b_file, c, '\n');
a += c;
}
if(a.compare("") == 0)
{ throw "That file does not exist.";}
b_file.close();
Help please?
-
Just use while( b_file ).
-
And give your 'try' an associated 'catch'.
-
Thanks X.
Zach - I have one later on, I didn't show all my code.
-
Sorry... I was having trouble counting the braces... again. :rolleyes:
-
No problem, that just means my indentation was off. Thanks for pointing that out. I've gotta get in the habit of easy-to-read code anyway.