Let's say you were not initializing students
at the same time you declared it; then the code would be:
students = malloc(numStudents * sizeof *students);
We don't even know what data type students
is here, however we can tell that it is mallocking the right number of bytes. So we are sure that there is not an allocation size error on this line.
Both versions allocate the same amount of memory of course, but this one is less prone to errors.
With the other version, if you use the wrong type in your sizeof
it may go unnoticed for a while. But in this version, if students
on the left does not match students
on the right, it is more likely you will spot the problem straight away.