C++ Basic string help
I'm programming in C++ and want to read a list of names from an input file and store it as a string vector. Would this code work?
Is there a better way that’s not too advanced?
-----------------------------------------------------------------------
ifstream fin;
fin.open("names.txt");
vector<string> NAME;
string person;
while( !fin.fail( ) ){
fin >> person;
NAME.push_back(person)
}
fin.close;
-------------------------------------------------------------------
Thanks for any advice!
__________________
Watch More TV
|