AS a side note


while (!feof(fp))

do not use feof to control input loop - read FAQ FAQ > Why it's bad to use feof() to control a loop - Cprogramming.com