Ok firstly I'll explain my assignment. For this assignment I have to use dynamic memory allocation which I am having no problems with. What I am having a problem with is figuring out the correct way to work my assignment. For my assignment I need to create a program that prompt the user to enter how many students they have then ask for the following information; Student ID, Birthdate, and Phone number. I need to use a loop to prompt the user to enter all the students information. I need to create a loop that will scan through all the student IDs and find the oldest student using their birthdate (The loop must be able scan through more then 3 students).
Here is my code, I've gotten some suggestions and even bits of code from you guys, but it's not allowing me to enter the students information when it gets to the for loop it just ends the program. Help
Thank you.
#include <stdio.h>
#include <stdlib.h>
struct studentDataType
{
int studentID;
int year;
int month;
int day;
long long phone;
};
int main (void)
{
int * studentData= NULL;
int * studentDataType;
int students;
int studentID;
int year;
int month;
int day;
long long phone;
printf("How many students are you entering records for:\n");
scanf("%d", &students);
studentData= malloc((sizeof(int)*students));
struct studentDataType *studentRecords = malloc(sizeof(struct studentDataType) * students);
for (int i = 0 ; i != students ; ++i) {
printf("Enter information for student %d\n", i+1);
struct studentDataType * s = &studentData[i];
scanf("%d%d%d%d%d", &(s->studentID), &(s->year), &(s->month), &(s->day), &(s->phone));
}
}