Background: Assignment for my class, create a program that checks the letters of a entered string.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int main()
{
const string key = "abcabcabcabcabcabcab";
int numstudents;
cout << "How many students took the test" << endl;
cin >> numstudents ;
while(numstudents>0)
{ string studentId;
string studentanswer;
cout << "enter student ID";
cin >> studentId;
cout << "enter answers of that student" << endl;
cin >> studentanswer;
numstudents--;
};
So the jist of the assignment is to grade answers that are inputted by the student with the answerkey.
Here's my problem. I can't figure out a way to make each inputted studentId assigned to its own variable, I don't want to replace studentId over and over again. It's inside the while loop. And once I figure out how to do that, I'm confused on how match each student answer to its corresponding studentId?
I'm not asking this forum to do my homework, I need advice/help on how to do this.
I misread the instruction! I managed to figure out a way to do it. Now, I have a new problem.
Now I'm trying to compare the studentanswer string to the key string, each character individually. I'm just using if statements for each character, but I feel like theres a much better way to do that.
How can I erase parts of a string, and how can I access just 1 character of a string?