fwrite(&temp, sizeof(int), count, binaryPointer);


shouldn't that be


fwrite(&temp, sizeof(int), 1, binaryPointer);


since you are writing one int each time through the loop. as it is,...