You aren't reading anything in because you fseek
ed to the end of the file. Do a fseek(fd, 0, SEEK_SET);
to return to the beginning of the file before you fread
.
If fread returns zero, then either of End-of-file or an Error occurred.
RETURN VALUE
fread() and fwrite() return the number of items successfully read or written (i.e., not the number of characters). If an error occurs, or the end-of-file is reached, the return value is a short item count (or zero).
fread() does not distinguish between end-of-file and error, and callers must use feof(3) and ferror(3) to determine which occurred.
I suggest you should check for errors on the file, and if an error occurred, you should print the relevant error message to get more information! This should be part of both your current debugging but also of the finished code as error handling.
Are you reading from the "rom" or writing to it?
It looks like your code moves to the end of the file and tries to read but finds nothing since it's at the end.