C 语言中可以使用 time.h 库中的函数 time() 和 ctime() 来获取当前时间并打印。
示例代码:
#include <time.h>
#include <stdio.h>
int main() {
time_t current_time;
time(&current_time);
printf("当前时间:%s", ctime(&current_time));
return 0;
}
输出结果:
当前时间:Wed Feb2 15:15:00 2023