View Single Post
Old 10-17-2004, 08:24 PM   #1 (permalink)
BuddyHawks
Swashbuckling
 
Location: Iowa...sometimes
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
BuddyHawks is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38