Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems Reading in from a file...

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
ok the txt file i'm reading from is structured like this...

1111 Johnny Smith 3.00 140.00
2222 Sammy Smith 4.00 173.00
etc...

I'm trying to read in each segment seperately into different structure members. My problem is when i try to read in the name segment I want it to stop reading at the end of the name but it continues to read in the entire rest of the line. For example, i use this code :

inputfile.seekg(6L, ios::beg);
inputfile.getline (EmpInfo[0].Name, 25)

and when i cout what was just retrieved, i get this output...

Johnny Smith 3.00 140.00

is there any way to get it to just read "johnny Smith" from the txt file?
 
Daverit40 (Visitor) Mar 26, 2002
ok the txt file i'm reading from is structured like this...

1111 Johnny Smith 3.00 140.00
2222 Sammy Smith 4.00 173.00
etc...

I'm trying to read in each segment seperately into different structure members. My problem is when i try to read in the name segment I want it to stop reading at the end of the name but it continues to read in the entire rest of the line. For example, i use this code :

inputfile.seekg(6L, ios::beg);
inputfile.getline (EmpInfo[0].Name, 25)

and when i cout what was just retrieved, i get this output...

Johnny Smith 3.00 140.00

is there any way to get it to just read "johnny Smith" from the txt file?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top