feof関数は、ふぁいるの終わりに到達した後に読込み操作を行なうと0以外を返すので

do {
 ret = fread(buf, sizeof(char), sizeof(buf), fp);
} while (!feof(fp));

で、どうよ?