thank you for reply , but I use C language .
F
Fossi Bluman
@Fossi Bluman
Posts
-
C fread to read 512k binary file -
C fread to read 512k binary filethen how to print the hexadecimal values in a format of two digits ?
-
C fread to read 512k binary filethis funny "fread" doing the job , exactly as i need , any way ,, how to make it not funny ?
-
C fread to read 512k binary fileI use the bellow code to read binary file but it throws an exceptions at run time and sometimes gives a wrong results , please tell me what's the wrong ?
#include
#includeunsigned long size,n;
int main()
{
unsigned char *buf;
FILE* fp;
fp=fopen ("myfile.bin","rb");
if (fp == NULL) {
fprintf(stderr, "Can't open the file");
exit(1);}fseek (fp,0,SEEK\_END); // size=ftell (fp); // get the size of the file fseek (fp,0,SEEK\_SET); // if ((buf=(unsigned char\*) malloc (size+1))==0) printf("\\n%s","allocation Error"); n=fread (buf,sizeof (buf),size,fp); printf ("\\n%02x %lu bytes read",buf\[15\],n); free (buf); fclose (fp); return 0;
}