原文地址:https://blog.csdn.net/ccsycl/article/details/37756113

#include <stdio.h>
#include<stdlib.h>
#include<string.h>
main()
{
        FILE *file;
        char *buffer;
        unsigned long fileLen;
        int i;
        file = fopen("aa.bin", "rb");
        if (!file)
        {
                fprintf(stderr, "can't open file %s", "1.m4v");
                exit(1);
        }


        fseek(file, 0, SEEK_END);
        fileLen=ftell(file);
        fseek(file, 0, SEEK_SET);
        printf("fileLen==%ld\n",fileLen);
        buffer=(char *)malloc(fileLen+1);


        if (!buffer)
        {
                fprintf(stderr, "Memory error!");
        fclose(file);
                exit(1);
        }


        fread(buffer, 1, fileLen+1, file);
        fclose(file);
        //printf("value is %s \n", buffer);
        for(i = 0;i < fileLen ;i++)
        {
     printf("%2x ",buffer[i]);
        if(i%16==15)printf("\n");
        if(i%4==3)printf("  ");
}
printf("\n");
free(buffer);

}


linux c 读取.bin文件

相关文章:

  • 2021-05-27
  • 2021-12-13
  • 2021-06-02
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-09
  • 2022-12-23
  • 2021-06-16
  • 2022-02-11
  • 2022-02-24
  • 2021-12-16
相关资源
相似解决方案