c說話strftime時光格局化示例。本站提示廣大學習愛好者:(c說話strftime時光格局化示例)文章只能為提供參考,不一定能成為您想要的結果。以下是c說話strftime時光格局化示例正文
函數原型:
size_t strftime (char* ptr, size_t maxsize, const char* format,const struct tm* timeptr );
代碼示例:
#include <stdio.h>
#include <time.h>
int main ()
{
time_t rawtime;
struct tm * timeinfo;
char buffer [128];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (buffer,sizeof(buffer),"Now is %Y/%m/%d %H:%M:%S",timeinfo);
puts (buffer);
return 0;
}