K
KK
Dear comp.lang.c++,
The code below reads off strings of a file into a vector.
ifstream srcfile("c:\\test.txt");
istream_iterator<string> strIter(srcfile), eos;
vector<string > strvec(strIter, eos);
say the file has the following data
c:\\test.txt
---------------
this is a test
to capture new line
after executing the above snippet, we have
strvec[] = {"this","is","a","test","to","capture","new","line"}
However, in this process the "new line" character information is lost.
How can I modify above snippet to capture the new line information too?
I want an ouput such that
strvec[] = {...,"test", "\n", "to",...}
Any suggestions,
Thank you
KK
The code below reads off strings of a file into a vector.
ifstream srcfile("c:\\test.txt");
istream_iterator<string> strIter(srcfile), eos;
vector<string > strvec(strIter, eos);
say the file has the following data
c:\\test.txt
---------------
this is a test
to capture new line
after executing the above snippet, we have
strvec[] = {"this","is","a","test","to","capture","new","line"}
However, in this process the "new line" character information is lost.
How can I modify above snippet to capture the new line information too?
I want an ouput such that
strvec[] = {...,"test", "\n", "to",...}
Any suggestions,
Thank you
KK