Created
December 18, 2015 04:43
-
-
Save hhc0null/00d812af52a0ac42ed7f to your computer and use it in GitHub Desktop.
myon
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 <string.h> | |
#include <assert.h> | |
#define TIME_PREFIX_SIZE 8 // "YYYYmmdd" | |
int main() | |
{ | |
struct tm *current_tm; | |
time_t current_time; | |
char buf[TIME_PREFIX_SIZE] = {}; | |
current_time = time(NULL); | |
current_tm = localtime(¤t_time); | |
assert(TIME_PREFIX_SIZE == strftime(buf, TIME_PREFIX_SIZE + 1 /* contains null byte */, "%Y%m%d", current_tm)); | |
printf("%d - ", strlen(buf)); | |
puts(buf); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment