#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <fcntl.h> #include <stddef.h> int main(){ int fd; struct tm *now; char haha[50]; time_t res; int cnt; fd=open("d:/log_info.txt",O_WRONLY|O_APPEND|O_CREAT); res=time(NULL); now=localtime(&res); printf("start time is: %s\n",asctime(now)); strcpy(haha,asctime(now)); if((cnt=write(fd,haha,strlen(haha)))==-1){ printf("wrong!!!!\n"); } else printf("cnt=%d\n",cnt); return 0; }
浙公网安备 33010602011771号