Display String Stored In Array

How would I get a name stored in the array cRoster[10] to display under "Class roster"? I know I somehow need the program to equate "string name" with cRoster[i], I'm just not quite sure how. Any advice is appreciated, thanks.


#include <string>
#include <cstdlib>
#include <iostream>
using namespace std;

int main ()
{
char xOption = ' ';
string cRoster [10];
int i = 0;
string name = "";

while (xOption != 'E')
{
cout << "Enter A for adding to the class." << endl;
cout << "Enter L for displaying roster.:" << endl;
cout << "Enter E to exit." << endl;
cout << "Choice:";
cin >> xOption;
xOption = toupper(xOption);
if (xOption == 'A')
{
cout << "Enter student's last name:";
cin >> cRoster[i];
i = i + 1;
}

if (xOption == 'L' && xOption != 'A' && xOption != 'E')
{
cout << "Number of students enrolled:" << i << endl;
cout << "Class roster:" << //? << endl;
}
}

system ("pause");
return 0;
}
Topic archived. No new replies allowed.