首页 > 代码库 > 读取二进制转换为字符串
读取二进制转换为字符串
#include<stdio.h> #include<stdlib.h>//为了使用exit() int swapInt32(int value) { return ((value & 0x000000FF) << 24) | ((value & 0x0000FF00) << 8) | ((value & 0x00FF0000) >> 8) | ((value & 0xFF000000) >> 24) ; } int main() { int a,b; FILE *outFp, *inFp; inFp=fopen("DMIMOLog.DAT","rb+"); if(inFp==NULL){ printf("open in file error!\n"); return 0; } outFp=fopen("DMIMOLog.txt","w+"); if(outFp==NULL){ printf("open outFp file error!\n"); return 0; } for(int i=0;i<8192*2;i++) { fread(&a,sizeof(int),1,inFp); b=swapInt32(a); //printf("%05x\r\n",b); fprintf(outFp,"%05x\r\n",b); } fclose(inFp); fclose(outFp); printf("finish\r\n"); }
读取二进制转换为字符串
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。