Skip to content

Instantly share code, notes, and snippets.

@snaewe
Created September 6, 2016 07:05
Show Gist options
  • Save snaewe/cb27a26cce645fb355ebf1a040ae2a07 to your computer and use it in GitHub Desktop.
Save snaewe/cb27a26cce645fb355ebf1a040ae2a07 to your computer and use it in GitHub Desktop.
Test if strftime sets errno
#include <time.h>
#include <stdio.h>
#include <errno.h>
int main(int argc, char* argv[])
{
time_t t = time(0);
char mbstr[100] = { 0 };
printf("errno: %d\n", errno);
size_t s = strftime(mbstr, sizeof(mbstr), ((argc>1) ? argv[1] : "%c"), localtime(&t));
if (s)
printf("%s\n", mbstr);
else
printf("errno: %d\n", errno);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment