Last active
February 19, 2022 12:09
-
-
Save camel-cdr/78dca38e09ff5391beabe9c1575248f0 to your computer and use it in GitHub Desktop.
C code that is syntactically correct only on Fridays
This file contains 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 <stdio.h> | |
#include <time.h> | |
static const char mon_name[12][3] = { | |
"Jan", "Feb", "Mar", "Apr", "May", "Jun", | |
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" | |
}; | |
int | |
main(void) | |
{ | |
static char str[] = "Mmm dd yyyy"; | |
struct tm it = {0}; | |
do { | |
mktime(&it); | |
sprintf(str, "%.3s %2d %4d", | |
mon_name[it.tm_mon], | |
it.tm_mday, | |
1900 + it.tm_year); | |
puts(str); | |
FILE *f = fopen(str, "w"); | |
if (it.tm_wday == 5) | |
fputs("#define ITS_FRIDAY 1", f); | |
fclose(f); | |
++it.tm_mday; | |
} while (it.tm_year < 10000 - 1900); | |
} |
This file contains 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 <stdio.h> | |
#include __DATE__ | |
#if !ITS_FRIDAY | |
:-) | |
#endif | |
int main(void) | |
{ | |
puts("Hello"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment