怎么用C語言創(chuàng)建一個(gè)文本文件?
#include <stdio.h>#include <time.h>int main(){ FILE *fp = NULL; char logName[20]={0}; time_t timep; struct tm *p; time(&timep); p = gmtime(&timep); sprintf(logName,"%d%02d%02d.txt",(1900+p->tm_year), (1+p->tm_mon), p->tm_mday); fp = fopen(logName,"a+"); fputs("test log\n",fp); fclose(fp); return 0;}//每天創(chuàng)建一個(gè)新文件,當(dāng)天日志都會(huì)追加到這個(gè)文件至于刪除文件也是一個(gè)道理,只要知道你要?jiǎng)h除多少天前的,拼接出名字直接刪除就好