以下代码应该可以正常工作(这是stackoveflow中公认的答案),但不知何故我收到了两个警告,因此我收到了分段错误。怎么了?
time_t timer;
char buffer[25];
struct tm* tm_info;
time(&timer);
tm_info = localtime(&timer);
strftime(buffer, 25, "%Y:%m:%d%H:%M:%S", tm_info);
bead.c:61: 警告:赋值使指针从没有强制转换的整数 bead.c:63: 警告:内置函数âstrftimeâ 的隐式声明不兼容
line 61 is tm_info = localtime(&timer);
and line 63 is strftime(buffer, 25, "%Y:%m:%d%H:%M:%S", tm_info);