0
Ifstream With Struct vector
Hey, im searching for a way to safe a vector in a file. you're thinking it's quite easy but here's a part of the code struct user { string name; int id; }; vector<user> userlist; I can get an input from the user and I can output the saved name and id but how can I read a .txt file? saving is quite easy I already got it.
2 Respuestas
+ 1
Make a method in your struct to read a single user object, and in a for loop, read data fron the file inside a temp object and push this object inside the vector. You will get your data.