|
Need help with reading from file
Hello,
I'm writing a database program using hashing, and I need to make it read in a file with a whole lot of names in it. Each field is separated by a space, and I'm not sure how to make the program read it in this way. The only way I've done file input before was with the getline function where each thing is on a different line.
The way I've used it before is like this:
for(int j=0; j<nItemsFile; j++)
{
infile.getline(tmpFirst,31);
infile.getline(tmpLast, 31);
infile.getline(tmpPhone,15);
infile.getline(tmpId,10);
infile.getline(tmpGender, 1);
}
I need something to read in fields like that but read them all from one line. The format of the input file is like this:
HEUSER TRACEY 3117622694 134321 M
RAMSBURG MCKINLEY 2640367707 135994 M
CHOUINARD NARCISA 9798195332 397412 F
PARISEAU BURT 2640444897 590617 M
FULMER RAELENE 2519542441 657893 F
MCGOWIN JULI 4123600135 544137 F
BOULAY ANJELICA 6360431978 226930 F
BUBLITZ KASEY 3531285948 035945 M
HOCKENSMITH DANA 8108996190 470636 M
Where the last name is first, then first name, phone, ID#, and gender respectively. If someone can help me out with a function or direct me to somewhere that can assisr it would be greatly appreciated!
Thank you
|