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

来源:互联网 发布:30岁男士护肤 知乎 编辑:程序博客网 时间:2024/05/22 23:27
 #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);
 }

0 0
原创粉丝点击