In this function, I'm trying to add multiple new records below current records. But after first input I get a crash.
void newRecords(char **firstname, char **lastname, float *score, int num)//integer function to add a record
{
firstname[num]=(char*)malloc(10*sizeof(char));
lastname[num]=(char*)malloc(10*sizeof(char));
int n;
printf("Enter number of records you want to add: ");
scanf("%d",&n);
printf("*USE FORMAT*\nEX)Steve Jobs 99\n");
printf("-----------------------------------------------------------\n");
for(int i=0; i<n; i++)
{
printf("Enter new student #%d record: ",i+1);
scanf("%s %s %f",firstname[num+i+1],lastname[num+i+1],&score[num+i+1]);
num+=1;//number of list is added
}
printf("\nNew records:\n");
printRecords(firstname, lastname, score, num);
}