c program 一問

2009-01-03 7:51 am
c program 有無function 記得個system時間,
example : 2009/1/3 23:50

回答 (1)

2009-01-03 7:04 pm
✔ 最佳答案
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
time_t now=time(NULL);
struct tm *tstr=localtime(&now);
printf("%s\n",asctime(tstr));
printf("%d/%d/%d %02d:%02d\n",tstr->tm_year+1900,tstr->tm_mon+1,tstr->tm_mday,
tstr->tm_hour,tstr->tm_min);
system("pause");
return 0;
}


收錄日期: 2021-04-13 16:20:31
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090102000051KK02405

檢視 Wayback Machine 備份