Created
December 28, 2015 04:43
-
-
Save dayt0n/f56f60b44a8ac31df510 to your computer and use it in GitHub Desktop.
timer written in C for my Advanced Computing class
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 <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main(int argc, char* argv[]) { | |
int time = 1; | |
if (argc > 2) { | |
printf("Too many arguments.\nusage: %s <end time in seconds>\n",argv[0]); | |
exit(0); | |
} | |
if (argc == 2) { | |
if(strcmp(argv[1],"-h") == 0 || strcmp(argv[1],"--help") == 0) { | |
printf("usage: %s <end time in seconds>\n",argv[0]); | |
return 0; | |
} | |
int quitTime = atoi(argv[1]); | |
for(int i = 0;i < quitTime;i++) { | |
system("clear"); | |
printf("%d\n",i+1); | |
sleep(time); | |
} | |
return 0; | |
} else { | |
for(int i = 1;i > 0;i++) { | |
system("clear"); | |
printf("%d\n",i); | |
sleep(time); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment