diff options
author | Holden Rohrer <hr@hrhr.dev> | 2020-02-02 13:34:33 -0500 |
---|---|---|
committer | Holden Rohrer <hr@hrhr.dev> | 2020-02-02 13:35:22 -0500 |
commit | 493f99109166c37feb58d0826de9a54880cb75b8 (patch) | |
tree | d501c7d1d7729473b76aaaaac99bc3a7ec90e9e6 | |
parent | e5cfafd3fcdfc249f040f8c1c3f89f5ff8ef8fe8 (diff) |
timer takes input in command instead of stdin
-rw-r--r-- | timer.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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); |