我想獲得ISO8601周編號C. MinGW安裝在我的電腦上。 GCC版本是5.3.0。你可以在下面看到我的代碼。 strftime對說明符「%V」不起作用。但它與指定符「%W」正常工作。但那不是我想要的。我需要ISO 8601格式的每週數字。ISO 8601周編號在C
我試過我的代碼與2不同的在線C編譯器,他們都工作得很好。我懷疑我的電腦上的編譯器配置不當。誰能告訴我我做錯了什麼?任何幫助,將不勝感激。
這裏是我的代碼:
#include <stdio.h>
#include <time.h>
#include <string.h>
int main()
{
time_t timep;
struct tm * time_inf;
char buff [80];
time (&timep);
time_inf = localtime (&timep);
time_inf->tm_year = 2008 - 1900;
time_inf->tm_mon = 11;
time_inf->tm_mday = 31;
mktime (time_inf);
strftime (buff, sizeof(buff), "%V", time_inf) ;
puts (buff); //prints nothing
printf("%d", strlen(buff)); //prints 0
return 0;
}
你的代碼適合我 - [點擊](http://coliru.stacked-crooked.com/a/af8765f61e764251)。請注意,'%V'格式說明符是語言環境相關的。嘗試挖掘這個,因爲代碼看起來很好 - *除了C不是C++ *。 – mpiatek