[help] reading a file
So, I'm trying to write a program which reads a file I wrote to input data into a program.
here's my file contents
What I want to do is have a whole line in one string. so I want to do something like :
vector <string> temp;
for(int i = 0; i < 4; i++)
file >> temp[i];
however, after inputting text2a, it ends the loop, and puts text2b into temp instead of temp, thus overloading the vector, and causing some pretty big problems.
My question : How would I go about putting 2 or more variables in one line from the file, into a single string, while the file itself has a variable of entities per given line?
Are you looking for
getline(file, temp[i]); ?
Looks like that's what I needed. Thanks!
Topic archived. No new replies allowed.