Created
November 1, 2018 00:12
-
-
Save john302/fe1485fb027169ad562cacc3543579fb to your computer and use it in GitHub Desktop.
Print a random fortune from an array.
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 <stdlib.h> | |
#include <time.h> | |
#include <unistd.h> | |
#include <string.h> | |
const char* x[] = { | |
"limerick", "fortunes2", "linuxcookie", | |
"freebsd-tips", "osfortune", "startrek", | |
"zippy", "debian-hints" | |
}; | |
const size_t FORTUNES = sizeof(x)/sizeof(*x) - 1; | |
int cool(int Size) { | |
int k; | |
k = 0; | |
srand((unsigned)time(NULL)); | |
k = rand() % Size; | |
return k; | |
} | |
int main() | |
{ | |
execlp("/usr/games/fortune", x[cool(FORTUNES)], "-l", NULL, NULL); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment