您的位置:首页 > 其它

获取当前系统时间并且转化成有效数据

2015-01-12 20:14 197 查看
 #include <stdlib.h>

#include <stdio.h>

#include <windows.h>

#include <time.h>

#include <string.h>

int main()

{

 time_t timep;

 time(&timep);

  int date,h,m,s,y;

 FILE *fp=fopen("1.txt","r+");

  char week[10],month[5];

 fprintf(fp,"%s",ctime((&timep)));

 fseek(fp,0,SEEK_SET);

 fscanf(fp,"%s %s %d %d:%d:%d %d",week,month,&date,&h,&m,&s,&y);

 printf("%s %s %d %d %d %d %d",week,month,date,h,m,s,y);

 fclose(fp);

 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: