69,368
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <time.h>
int main()
{
time_t s;
struct tm *p;
FILE *fp;
char *fname="timenow.txt";
s=time((time_t*)NULL);
p=gmtime(&s);
fp=fopen(fname,"w+");
fprintf(fp,"%d-%d-%d %d:%d:%d\n",1900+p->tm_year,1+p->tm_mon, \
p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec);
fclose(fp);
printf("Year:%d\n",1900+p->tm_year);
printf("Month:%d\n",1+p->tm_mon);
printf("Day:%d\n",p->tm_mday);
printf("Hour:%d\n",p->tm_hour);
printf("Minute:%d\n",p->tm_min);
printf("Second:%d\n",p->tm_sec);
return 0;
}
#include <stdio.h>
#include <time.h>
int main()
{
time_t s;
struct tm *p;
FILE *fp;
char *fname="timenow.txt";
s=time((time_t*)NULL);
p=gmtime(&s);
fp=fopen(fname,"w+");
fprintf(fp,"%d-%d-%d %d:%d:%d\n",1900+p->tm_year,1+p->tm_mon, \
p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec);
fclose(fp);
printf("Year:%d\n",1900+p->tm_year);
printf("Month:%d\n",1+p->tm_mon);
printf("Day:%d\n",p->tm_mday);
printf("Hour:%d\n",p->tm_hour);
printf("Minute:%d\n",p->tm_min);
printf("Second:%d\n",p->tm_sec);
return 0;
}
#include <stdio.h>
#include <time.h>
int main()
{
time_t s;
struct tm *p;
FILE *fp;
char *fname="timenow.txt";
s=time((time_t*)NULL);
p=gmtime(&s);
fp=fopen(fname,"w+");
fprintf(fp,"%d-%d-%d %d:%d:%d\n",1900+p->tm_year,1+p->tm_mon, \
p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec);
fclose(fp);
printf("Year:%d\n",1900+p->tm_year);
printf("Month:%d\n",1+p->tm_mon);
printf("Day:%d\n",p->tm_mday);
printf("Hour:%d\n",p->tm_hour);
printf("Minute:%d\n",p->tm_min);
printf("Second:%d\n",p->tm_sec);
return 0;
}