summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-02-02 13:34:33 -0500
committerHolden Rohrer <hr@hrhr.dev>2020-02-02 13:35:22 -0500
commit493f99109166c37feb58d0826de9a54880cb75b8 (patch)
treed501c7d1d7729473b76aaaaac99bc3a7ec90e9e6
parente5cfafd3fcdfc249f040f8c1c3f89f5ff8ef8fe8 (diff)
timer takes input in command instead of stdin
-rw-r--r--timer.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/timer.c b/timer.c
index 7000727..0e4ce7c 100644
--- a/timer.c
+++ b/timer.c
@@ -1,11 +1,10 @@
#include <stdio.h>
#include <unistd.h>
-int main(){
+int main(int argc, char** argv){
int min; int sec;
- printf("Input #minutes:#seconds ");
- scanf("%d:%d", &min, &sec);
- printf("\n");
+ if (argc != 2) return 1;
+ sscanf(argv[1], "%d:%d", &min, &sec);
int time = min*60 + sec;
for (int i = 1; i<=time; i++){
printf("%d:%02d/%d:%02d\r", (i-i%60)/60, i%60, min, sec);