File I/0 copying all of file

Hi Guys

Sorry for asking for help, but I have an issue.

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.

Thanks for your help guys.
You have to use the substring method to remove the part of the string that is the number and the part of the string that is the name.
Just looked up substring, should be able to do it, thank you :)
Topic archived. No new replies allowed.