KingOfMalkier n00b
Joined: 03 Apr 2003 Posts: 47
|
Posted: Mon May 12, 2003 4:30 am Post subject: C++ -- reading in an entire file |
|
|
I want to read in an entire file in C++, but I've been having issues with newlines. Right now I can get the whole thing using readline and manually adding newlines...
Code: | //current_file is a string
ifstream infile;
infile.open(current_file.c_str());
string temp = "";
while(!getline(infile, temp).eof())
{
//...copy temp to a gtk TextBuffer and put back newlines
text_defs->get_buffer()->insert_at_cursor(temp);
text_defs->get_buffer()->insert_at_cursor("\n");
}
infile.close(); |
Problem is, if I repeat the process on the same file, it keeps adding newlines to the end of the file.
It seems like just not adding that last newline would be easy, but I've had no luck so far. I've looked for different methods of reading as well, but nothing has panned out. |
|