In the following code I'm suppose to display 2 students information.
Their names and 10 answers for a test.
Alan Baker a,b,b,d,c,a,d,b,d,d
Rodney Bill b,c,d,a,b,d,a,c,d,a
the problem I'm running into is I'm having a problem entering my answers into the char array included in the structure Student_Info.
then in the display I need to display the answers in the order above for each name
If anyone could help me by showing me what I'm missing or doing wrong, that would be appreciated
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
//structure created to hold student answers and name
struct Student_Info{
string last_name;
string first_name;
char student_test_answers[10];
};
//there will be 2 students
Student_Info student[2];
//function to preset name and answers
void students_name_and_answers(){
student[1].first_name="Alan ";
student[1].last_name="Baker";
//the following line is where I am having a problem
student[1].student_test_answers = {'b','a','t'};
student[2].first_name="Rodney ";
student[2].last_name="Bill";
}
//function for display
void Display_Information()
{
//for loop to cout students information
for(int x = 1;x <3;x++)
{
cout<<student[x].first_name<<student[x].last_name<<"'s answers are ";
//the following line is the display for the answers
//cout << students_test_and_answers;
}
}
//functions called into the main
int main(){
students_name_and_answers();
Display_Information();
}
| |