From 493f99109166c37feb58d0826de9a54880cb75b8 Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Sun, 2 Feb 2020 13:34:33 -0500
Subject: timer takes input in command instead of stdin
---
timer.c | 7 +++----
1 file 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
#include
-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);
--
cgit