调试的时候,如果需要打印当前时间,time()函数有点复杂,可以直接借助串口软件;
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
time_t cur_time; //定义变量
time(&cur_time); //获取当前时间
printf("%s",ctime(&cur_time)); //将当前时间转换为字符串并输出
system("pause");
return 0;
}
//见下图黄色勾选部分