你可以参考这个函数strftime.我会告诉你如何使用它:-)
既然你声称已搜索过它,我会提供答案:
// first of all, you need to include time.h
#include<time.h>
int main() {
// then you'll get the raw time from the low level "time" function
time_t raw;
time(&raw);
// if you notice, "strftime" takes a "tm" structure.
// that's what we'll be doing: convert "time_t" to "tm"
struct tm *time_ptr;
time_ptr = localtime(&raw);
// now with the "tm", you can format it to a buffer
char date[11];
strftime(date, 11, "%d/%m/%Y", time_ptr);
printf("Today is: %s\n", date);
}
Run Code Online (Sandbox Code Playgroud)