I have this function, I realocate memory, but when i want to read string it doesn't work=>error Student is a Struct
void insertStudent(Student **myStudents, int *size)
{
int newSize = *size + 1;
*myStudents = (Student*)realloc(myStudents, newSize*sizeof(Student));
printf("Enter your grade: ");
scanf("%f", &(*myStudents)[*size - 1].nota);
printf("Enter your first name: ");
scanf("%s", &(*myStudents)[newSize-1].firstName);
printf("Enter your second name: ");
scanf("%s", &(*myStudents)[*size - 1].lastName);
//Generate a new code
/*int code = rand() % 1+1000;
int ok = 0;
while (ok == 0)
{
ok = 1;
for (int i = 0; i < *size; i++)
if ((*myStudents)[i].cod == code)
{
code = rand() % 1 + 1000;
ok = 0;
}
}*/
(*myStudents)[*size-1].cod = 7;
printf("Your code is: %d. Do not forget it! ", 7);
}