Why does strptime() behave differently on OSX and on Linux?
问题 Consider this program: #include <stdio.h> #include <time.h> int main() { struct tm t; strptime("2015-08-13 12:00:00", "%F %T", &t); printf("t.tm_wday = %d\n", t.tm_wday); return 0; } Under OSX, this is what I obtain: $ gcc test_strptime.c $ ./a.out t.tm_wday = 0 But on Linux, this is what I get: $ gcc test_strptime.c $ ./a.out t.tm_wday = 4 Why is the bahaviour different? I would expect the day of the week to be well defined, given the data and the time of the day? 回答1: The Linux (glibc) and