-
writing in arrays
here is an excerpt from my homework that I'm having some difficulty with and need some direction.
"Selecting 2 Prompts the user for a first and last name. Store this information in the system as a student record.
You should be able to handle 1000 students.
Student records have
First name,
Last name,
Student ID,
A list of grades (up to 100 classes). Grades are entered in grade point format (4.0 for an A)
"
Basically I have an array where each index is a student and in each index there are the different variables like: first name, last name, ID, and grade. and im having a problem when i have someone input a students first and last name, how would i have it store it inside the first and last name array. This is what i wrote for this part.
Code:
else if (a == 2)
{
printf("Enter a first name and a last name\n");
scanf("%s%s",
}
-
Examples.
An array.
Code:
char name[100];
scanf("%s",name);
An array in a struct.
Code:
struct student {
char name[100];
};
struct student s;
scanf("%s",s.name);
An array in an array of struct.
Code:
struct student {
char name[100];
};
struct students s[20];
scanf("%s",s[0].name);