Created
September 6, 2016 07:05
-
-
Save snaewe/cb27a26cce645fb355ebf1a040ae2a07 to your computer and use it in GitHub Desktop.
Test if strftime sets errno
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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