23,110
社区成员
发帖
与我相关
我的任务
分享
#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 右键 16进制显示~~
ue 右键 16进制显示~~