I'm doing a basic assignment that involves reading strings and numerical values from a text file, and the resulting output must be aligned a certain way. Here's a small example of the file data being input to the program:
1 2 3
|
John Smith#40
Jane Doe#45
Harry Morgan#40
|
In Notepad, the new line characters don't appear, and it looks like a line of text, but there are clearly new line characters here between the integers and the next string.
So my code to read the input of the file looks like so. Please assume the file has been properly opened and the data is successfully input as shown, because it is.
1 2 3
|
getline(fileInput,employeeName,'#');
fileInput>>hoursWorked;
cout<< setw(22) << name << setw(10) << hours;
|
The widths 22 and 10 are the same widths as the header before it, and the first line of data is output correctly, in line with the header. The problem is with EVERY line afterward... Here is an example of what the result looks like
1 2 3 4
|
Name Hours
Person A 40.00
Person B 45.00
Person C 45.00
|
Every line after seems to align incorrectly even though the cout instruction is identical... so, why exactly is this???