Coming soon - Get a detailed view of why an account is flagged as spam!
view details
3
Array of strings questions
Post Body

For my homework for class I have to make a program that you get student names from the user, then get test grades for each student and the program averages them and gets letter grade. My output is somewhat of a table with the first column being names, then letter grade, and then average. Is there a way to make the array of the names to format so that the second column will be lined up? Because currently if the names have more letters it isn't even. Relevant code I have is this:

const char STUDENTNAMES = 11;
const int NUMSTUDENTS = 5;
char students[NUMSTUDENTS][STUDENTNAMES]; 

cout << "Student--Letter Grade--Average\n";
cout << "-------------------------------\n";
for (displayLoop = 0; displayLoop < NUMSTUDENTS; displayLoop  ){
    cout << students[displayLoop] << "  " << letterGrade[displayLoop] << "     " << studentAverages[displayLoop] << endl;
}                   

Example of what I want:

Student-----Letter Grade--Average
------------------------------------------
Bob         B             85
Alexander   D             67

Example of what I get:

Student-----Letter Grade--Average
------------------------------------------
Bob   B             85
Alexander   D             67

Author
Account Strength
100%
Account Age
13 years
Verified Email
Yes
Verified Flair
No
Total Karma
79,654
Link Karma
15,292
Comment Karma
64,058
Profile updated: 2 days ago
Posts updated: 9 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
11 years ago