The following code should be working (it’s an accepted answer in stackoveflow), but somehow I get two warnings and as a consequence I get a segmentation fault. What’s wrong?
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: warning: assignment makes pointer from integer without a cast
bead.c:63: warning: incompatible implicit declaration of built-in function âstrftimeâ
line 61 is tm_info = localtime(&timer);
and line 63 is strftime(buffer, 25, "%Y:%m:%d%H:%M:%S", tm_info);
So… The compiler thinks
localtimereturns an integer andstrftimedoes not exist?Are you sure you’re including
<time.h>?