or needed sleep.
So here is another stupid question:
getline is suppose to read characters unti:
num - 1 characters have been read,
a newline is encountered,
an EOF is encountered,
or, optionally, until the character delim is read. The delim character is not put into buffer.
so why is the following:
void
readRep (const string & in, vector <string> & v)
{
string temp;
ifstream ins(in.c_str());
while (! ins.eof())
{
getline (ins, temp, '#' );
v.push_back(temp);
}
ins.close();
}
void write (const vector <string> & v)
{
for (unsigned int x = 0; x < v.size(); x++)
cout <<"v["<< x << "]: "<< v[x] << endl;
}
int main ()
{
readRep ("replace.txt", replace);
write (replace);
return 0;
}
displaying:
v[0]: Mark
v[1]: CSCI362
Dave
v[2]: CSCI420
and not:
v[0]: Mark
v[1]: CSCI362
v[2]: Dave
v[3]: CSCI420
where replace.txt contains:
Mark#CSCI362
Dave#CSCI420