-
-
Save mu578/13e446c3665f020ad1f4ec8083fca007 to your computer and use it in GitHub Desktop.
Useless C
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
// cc u1.c -pedantic -Wno-newline-eof -o u1.executable | |
#include <stdio.h> | |
# if defined(_MSC_VER) | |
# include <windows.h> | |
static int usleep(__int64 usec) | |
{ | |
HANDLE timer; | |
LARGE_INTEGER fire; | |
fire.QuadPart = -(10 * usec); | |
timer = CreateWaitableTimer(NULL, TRUE, NULL); | |
SetWaitableTimer(timer, &fire, 0, NULL, NULL, FALSE); | |
WaitForSingleObject(timer, INFINITE); | |
CloseHandle(timer); | |
return 0; | |
} | |
# else | |
# include <unistd.h> | |
# endif | |
int main(int argc, const char * argv[]) | |
{ | |
int i = 1; | |
(void)argc; | |
(void)argv; | |
for (; i < 10; ++i) { | |
fprintf(stderr, "\033c\033[0;31m%d\033[0m", i); | |
usleep(1000 * 1000); | |
} | |
fprintf(stderr, "\033c"); | |
return 0; | |
} | |
/* EOF */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment