#include
#include
#include
int main(int argc, char *argv[])
{
FILE *fp;
fp=fopen("test1.txt","w+");
if(fp == NULL){
perror("fopen");
}
else{
printf("the fild is open! \n");
}
char p[1024];
while(1){
time_t tim = time(NULL);
struct tm *tm = localtime(&tim);
snprintf(p,sizeof(p),"%d %d %d %d %d %d\n", tm->tm_year+1900, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
sleep(1);
fputs(p, fp);
}
fclose(fp);
阅读(1774) | 评论(0) | 转发(0) |