Hey, I want to know the best way to read files.
1 2 3 4
|
ifstream infile;
int x;
char y, *yy;
string z;
|
For each of the 4 variable types, what is the best way to read the form the file?
Also, if I want a delimiter, how would I use that?
Currently I have:
getline(infile, z, ".");
That wont work. (I want it to collect everything into the string, up until the full stop.
Also what are the specifics, if you could please list them for the approaches you list.
e.g.
infile >> x;
collects first integer, does it leave whitespace to be read by the next thing? Or does it remove the whitespace from the buffer?
Because if it does, what if I wanted something like say:
infile >> x;
infile >> z;
Where there .txt file reads:
15:test'.
Would z = :test'. or test'.
Thanks in advance.