>grades2 = malloc(numberOfRecords * sizeof(int));
The part in red is where you want to tell malloc how big each record is. Let the compiler do the work for you by taking the sizeof the first element of the array.