With the following input: Joe John 10001 45 25.00 Random Guy 10002 35 20.00 Incorrect Input 10003 -10 5.00 An Employee 10004 10 15.00 One More 10005 25 25.00
And I keep getting the following output: Employee name Hourly pay rate Hours worked Tax rate Gross pay Net pay Joe John 25 45 0.1 1012.5 1125 andom Guy 20 35 0.1 630 700 n Employee 15 10 0.1 135 150 ne More 25 25 0.1 562.5 625
An error has occurred while processing the following data Employee name Hourly pay rate Hours worked Tax rate Gross pay Net pay ncorrect Input 5 -10 0.1 -45 -50
For some reason, the first letter of the names coming after Joe John are being omitted. Please help, I cannot figure out why this is happening. Thank you very much in advance!
is the problem. because >> reads in characters and not the line feed it will read in the next char which is the first character of the next employees name hence the missing letter.
try this instead:
1 2
if ( inData.peek() == '\n')
inData.ignore(1);
the ignore function will read and discard the WHATEVER the next character is (in this case the new line) so everything will now be correct.