FIL* fdst=0; //文件对象
FRESULT res;
UINT bw;
u8 *pname=0;
fdst=(FIL *)gui_memin_malloc(sizeof(FIL)); //开辟FIL字节的内存区域
RTC_Get();//更新时间
pname=gui_memin_malloc(40);//申请40个字节内存,类似"0:TEXT/TEXT20120321210633.txt"
pname[0]='\0';//添加结束符
sprintf((char*)pname,"%04d年%02d月%02d日%02d时%02d分%02d秒\r\n",calendar.w_year,calendar.w_month,calendar.w_date,calendar.hour,calendar.min,calendar.sec);
//fdst.fsize=0;
res = f_open(fdst,"0:/TEXT/001.txt", FA_READ | FA_WRITE | FA_OPEN_ALWAYS);//打开文本,while之前已经
if( res == FR_OK)
{
Show_Str(0,0,240,16,"磁盘正常",16,0);
res = f_lseek(fdst,fdst->fsize);
res = f_write(fdst,(const TCHAR*)pname, sizeof((const TCHAR*)pname), &bw);
f_close(fdst);
}
}
gui_memin_free(fdst);
gui_memin_free(pname);
请各位大侠帮我看看这上面的程序 只能把年份 2014 写入TXT文本。后面的月 时分秒 都不能写入。 |