struct exam question[3];
defining question
in this way, that means your are defining array of 3 elements. each element in the array is an exam
structure
And it could be filled like this:
strcpy(question[0].quest, "What's the name of The President?");
strcpy(question[0].ans1, "name 1");
strcpy(question[0].ans2, "name 2");
strcpy(question[0].ans3, "name 3");
question[0].correct_answer = 2;
strcpy(question[1].quest, "What's the surname of The President?");
strcpy(question[1].ans1, "surname 1");
strcpy(question[1].ans2, "surname 2");
strcpy(question[1].ans3, "surname 3");
question[1].correct_answer = 3;
And you can fill it in this way too:
struct exam question[3] = {
{"What's the name of The President?", "name 1", "name 2", "name 3",2}
{"What's the surname of The President?", "surname 1", "surname 2", "surname 3",3}
{"What's any thing?", "any thing 1", "any thing 2", "any thing 3",3}
}