I am copying a file into different vectors dependent on the type of variable it is e.g int,string,double etc.
Numbers in the .txt file copy fine into the int vectors, however if I am trying to copy names, into a string vector, it just copies everything in the file.
code below ( if its stupid I'm sorry, I'm not a very good programmer)
1 2 3 4 5 6 7 8 9 10 11 12 13
myfile.open("customers.txt");
while (! myfile.eof())
{
getline( myfile,line);
istringstream getname(line);
if ( getname >> tmpname)
{
name.push_back(tmpname);
}
}
myfile.close();
Note that have used the getline method for the ints also, and they are copying fine.