日期:2014-05-16 浏览次数:20808 次
#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;
}