Aug 1, 2012 at 5:48pm Aug 1, 2012 at 5:48pm UTC
I'm taking a guess, '~'
is used as a delimiter throughout the file? If so, then you need to extract it between extracting hoursWorked and payRate.
It would help to see the formatting of the file.
Aug 1, 2012 at 7:03pm Aug 1, 2012 at 7:03pm UTC
The quick and dirty method is to declare a
char junk;
and extract that second '~' before payRate:
1 2
getline(Employeer, fullName, '~' );
Employeer >> hoursWorked >> junk >>payRate;
Though I wonder if that '\n' after "40" is going to make "hanson", "\nhanson". Might be wise to use cin.get() after extracting payRate.
A more flexible way to do this would be to extract the entire line as one string, and then use the delimiter to parse that.
Last edited on Aug 1, 2012 at 7:03pm Aug 1, 2012 at 7:03pm UTC
Aug 1, 2012 at 8:07pm Aug 1, 2012 at 8:07pm UTC
You might be interested in strtok()
from <cstring>
.