I'm trying to display the data but I'm getting nothing instead...
Could someone please help me understand what I'm doing wrong?
Thanks!
Note: This is for a homework assignment and I've coded much of it (removed from the testcase, of-course), this is one part I can seem to work out though and I've been stuck on it for over an hour... The professor stated that we were supposed to use char arrays instead of strings and that getline() should also be used.
You see "In loop!" because 'endl' calls flush(). The other output don't have an 'endl' and hence no flush. The command 'pause' is not found and so the program ends without showing the non flushed output (maybe it shows but you're not able to see it)
The size you pass to getline() should account for a null character to terminate the string (eg. if you wish to read in 5 characters, your size should be 6).
Your fixed widths look a little off too..
5 20 9 9 9
|---||------------------||-------||-------||-------|
1 Item one 11 12 13
2 Item two 12 13 14
3 Item three 13 14 15
Also, are you supposed to be reading all of the input into character arrays? as it does not make much sense to treat the numbers as strings.
sloppy, right now I'm just trying to get access to the data period... Once I get things displaying, I'll worry about datatypes... :-/
I've been stuck on this for like 5 hours and I'm going insane... :-/ Is there a better way to read the fixed width columns? Could you demonstrate an example of it if so as I've tried a bazillion things since making the initial post and at this point, the only way I'm going to learn is by seeing something that actually works as I'm about to throw my towel in and give up on it soon...
Also, [0] - [4] is 5, is it not? Don't you count 0 and 1?