c语言 二进制文件写入的问题,求版主解决一下

布鲁克斯南南 布鲁克斯南南 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
代码如下:
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include "M_dongjieliang.h"

#define filename "meter_djl.log"

int main()
{
FILE *fp;
int ret;
struct M_Dongjie_L M_DJL;
//unsigned char *buff = "aaaaa";
unsigned char temp[8]={0x41,0x41,0x41,0x41,0x41,0x41,0x31};
unsigned char t[7] = {0x12,0x11,0x10,0x17,0x07,0x0d};


fp = fopen(filename,"rb+");
if(!fp)
{
fp = fopen(filename,"wb+");
return -1;
}
// M_DJL.m_num =0x01;
//memcpy(M_DJL.m_djl_val,temp,8);
// memcpy(M_DJL.save_time,t,7);
//ret = fwrite(M_DJL.save_time,sizeof(struct M_Dongjie_L),1,fp);
ret = fwrite(temp,1,8,fp);
if(!ret)
perror("fwrite");
printf("%d\n",ret);

fclose(fp);
return 0;
}



我现在需要写入的是二进制的文件,现有如下的疑惑,我想用UE 打开时显示的是这样的

但是现在显示的是这样的

,要怎么解决啊
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部