i defined a structure for a student
typedef struct {
char firstName[20];
char lastName[20];
int id;
char *birthDate;
} Student; the function definition for a student is this
Student createStudent(const char first_Name, const char last_Name, int ID, const char
birthDate_str) {
/* Declare a structure */
Student *b = ((Student *)malloc(sizeof(Student)*1));
strcpy(b->firstName, first_Name);
strcpy(b->lastName, last_Name);
strcpy(b->birthDate, birthDate_str);
b->birthDate = (char *) malloc(sizeof(char) * strlen(birthDate_str)+1);
strcpy(b->birthDate, birthDate_str);
b->id = ID;
return b;
} i need to use a for loop to print each student that i created
Student s3 = createStudent("Jamie", "Peters", 1445562, "07/11/1988");
Student s4= createStudent("Chris", "Johnson", 340672, "05/10/1960");
Student s5 = createStudent("Belle", "Peters", 685590, "01/25/1998");
Student s6 = createStudent("Liz", "Erickson", 6792390, "11/15/2005");
Student s7 = *createStudent("Halle", "Smith", 123456, "02/14/2014");`
i have a student array to store each student's information
char *studentArray[6];
I want to use a for loop so that when the studentArray is at position 1 for example it would print information for student 3 (s3) and so on for each position. it should print like this
printf( "First Name : %s\n", student->firstName);
printf( "Last Name : %s\n", student->lastName);
printf( "Birthday : %s\n", student->birthDate);
printf( "ID : %d\n", student->id);
I cant figure out how to print using a for loop any help would be apreaciated.