I assume that this will not work on the first iteration of the while , but rather will continue to read the file until you reach the end of the file, after which fread() will return 0 and your program will exit.
The reason he does not find the signature is this:
memcmp(array,"0xffd8ffe0",4)==0
This memcmp() call is almost certainly not what you want (it looks for the ASCII character sequence '0' , 'x' , 'f' and 'f' ).
PS As noted in the comments of @Mat, for maximum portability, you should open the file in binary mode ( "r+b" instead of "r+" ).
source share