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.

11th Jul 2018, 7:07 AM
Talha Hameed
Talha Hameed - avatar
2 odpowiedzi
+ 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.
11th Jul 2018, 12:35 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar