I have a pretty standard assignment to input students names/test scores into an array of structs. Then I need to output the names, scores, and letter grade. I have the program written and working fine, but my issue is with the output.
The assignment states to keep output left justified (for some reason). My string are different lengths and it throws off my columns. Very rough example:
1 2
cout << left << b << "," << setw(15) << a << setw(15) << grade1 << gr1 << endl;
cout << left << d << "," << setw(15) << c << setw(15) << grade2 << gr2 << endl;
My output is:
bounty,dog 97 a
shore,paulie 67 d
Is there an easy way to keep different length strings from screwing up my columns?
Hi there, I am new to c++ and I am not 100% sure if this might help but I think there is a string function that allows you to get the amount of used character spots in the array. If so you could add something like s1.count(I am not certain) for each one on each side and make it so it gets the range (something like s2.count - s1.count) and turns that number into an amount of spaces in a for loop in a function. Again, I am not certain of this but maybe it will give you an idea (also I often think things are more complicated than in reality.) Good Luck :D