C语言加变量

2025-05-14 13:51:48
推荐回答(2个)
回答1:

#include
time_t now; //加 time_t 型
now=time(NULL); // 获取当前时间。
printf("%s",ctime(&now)); // 很容易输出。

加结构成员:
struct student
{ int id;
char name[100];
int score;
time_t now;
};

回答2:

#include

clock_t currentTime = clock(); //获得从1970年1月1日到当前的毫秒数

具体函数百度查询time.h头文件即可