I'm trying to use fstreams to format/encode a text file in a way that is useful for another program of mine, and I came upon a little snag...
The input file is formated as such:
int (line count)
string (line)
string (line)
string (line)
etc...
obviously, I start by reading in the integer and then proceed to use getline to try and get the strings, but the problem that I'm having is that getline won't pull the strings, and thus I'm not able to format them:
in and out are the ifstream and ofstream, respectively. The string seems to come in as an empty string. Both outputting it and attempting to format it reveal this. It's quite likely that I'm missing/forgetting something stupidly simple, but it's been awhile since I've written anything with straight c++ code. Any insight would be appreciated.
The input file is formated as such:
int (line count)
string (line)
string (line)
string (line)
etc...
obviously, I start by reading in the integer and then proceed to use getline to try and get the strings, but the problem that I'm having is that getline won't pull the strings, and thus I'm not able to format them:
Code:
int line_count(0);
string s;
int word_count(0);
in >> line_count;
out << line_count;
for(int i=0; i<line_count; ++i)
{
...
getline(in, s);
...
}
Comment