I am trying to compile this simple example on Windows. When I use %F
, which is a shortcut for the longer form of %Y-%m-%d
, the process aborts with no error message. On Linux, it works fine as in this live example shows on ideone.com. Any ideas?
#include <stdio.h>
#include <time.h>
int main ()
{
time_t rawtime;
struct tm * timeinfo;
char buffer [80];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (buffer,80,"Now it's %F.",timeinfo);
puts (buffer);
return 0;
}
%F
is C99, see strftime on man7 or compare the C99 and C90 standards yourself.
strftime
in the VS2013 library and earlier are not C99-conformant, as they do not accept that format-specifier: MSDN VS2013 strftime
page
Maybe the next version will add it, as the format is not used for anything else yet...
Just use the format it's a shortcut to directly, that's C89 and VS2013 conformant: %Y-%m-%d
Quote for what happens with an invalid format specifier passed to strftime
from the C standard:
6 If a conversion specifier is not one of the above, the behavior is undefined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With