1
#include <langinfo.h>
#include <stdio.h>

int main(int argc, char **argv){

char *firstDayAb;
firstDayAb = nl_langinfo(ABDAY_1);
printf("\nFirst day ab is %s\n", firstDayAb);

return 0;
}

This code works fine on Mac and Linux but it doesn't work on windows due to absence of langinfo.h. How to avoid using langinfo.h? Or maybe there is another way of getting abbreviated weekday name?

4

2 回答 2

3
#include <stdio.h>
#include <time.h>

int main ()
{
  struct tm timeinfo = {0};
  char buffer [80];
  timeinfo.tm_wday = 1;
  strftime (buffer, 80, "First day ab is %a", &timeinfo);
  puts (buffer);      
  return 0;
}
于 2012-07-14T19:04:14.817 回答
0

我发现这里给出了头文件的链接代码。它在 Windows 上使用 KDE32。我希望这可以帮助你。

于 2012-07-14T18:55:31.173 回答