Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //A quick and dirty program to print a randomly colored, randomly generated stream of numbers.
- //Released as wtfpl and whatnot. http://www.wtfpl.net/about/
- /*version 3.2: adding srand() broke it so goodbye srand()*/
- #include <stdio.h> //I/O Junk
- #include <stdlib.h> //used for rand()
- #include <unistd.h> //used for usleep()
- int main(){
- int speed, input;
- printf("Select the speed:\n\t1 (Slow)\n\t2 (Medium)\n\t3 (Fast)\n");
- scanf("%d", &input);
- switch(input){
- case 1 :
- speed = 10000; //speed should be in microseconds, blame usleep.
- break;
- case 2 :
- speed = 5000;
- break;
- case 3 :
- speed = 1000;
- break;
- default:
- printf("\nInvalid input. Reverting to default (Fast).\n");
- speed = 1000;
- break;
- }
- while(1){
- usleep(speed);
- fflush(stdout);;
- //jury rigged random color and number generator. Hey, it works.
- printf("\033[22;3%dm %d", rand() % 10, rand() % 10);
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement