cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Storing tricky data from text file into
Storing tricky data from text file into array
Nov 19, 2012 at 7:16am UTC
llbeanfan
(1)
I am trying to store data of the following format from a text file into different arrays for each component:
Last name, First name
ID Year
For example:
Griffin, Peter
4737 2012
When I am using ifstream fin as a file handler, is this the correct idea?
getline(fin, lastname[counter], ',');
getline(fin, firstname[counter])
getline(fin, id[counter], ' ');
getline(fin, year[counter]);
In particular would the bold above be correct? I am confused about how to extract the first name without also extracting the comma and the space before the first name.
Thanks!!
Topic archived. No new replies allowed.