symons

___________每一天都是幸福的!!

  博客园  ::  :: 新随笔  ::  :: 订阅 订阅  :: 管理
#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;
}

 

posted on 2013-12-18 19:52  symons  阅读(160)  评论(0)    收藏  举报