c++ - Aligning data which contains strings -


i'm online student c++ course. intended output should so...

intended output

instead looks

output program

my code fr follows

for (int = 0; < 20; i++){             outfile << left << setw(25)                 << studentlist[i].studentlname + ", " + studentlist[i].studentfname                 << right << " " << setw(6) << studentlist[i].testscore                 << setw(6) << " " << studentlist[i].grade << endl; 

yes, data correct. cannot clear answer on how align testscore output in exact same column spaces, because setw begins when student name strings end, varies, , therefore makes adjacent code uneven.

setw sets width of next element insert. concatenate last name, comma , first name temp string, set width , insert temp string.


Comments