C语言获取系统当前时间并格式化输出的代码如下:
#include <stdio.h>
#include <time.h>
int main()
{
time_t rawtime;
struct tm *timeinfo;
char buffer[80];
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", timeinfo);
printf("当前时间: %s\n", bu