summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-02-02 13:22:53 -0500
committerHolden Rohrer <hr@hrhr.dev>2020-02-02 13:22:53 -0500
commitf02ac2c933a33a363035ae478071759f87048e92 (patch)
treea59432de5e4018a4280b151c8db9cd91925d91db
added timer
-rw-r--r--timer.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/timer.c b/timer.c
new file mode 100644
index 0000000..7000727
--- /dev/null
+++ b/timer.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <unistd.h>
+
+int main(){
+ int min; int sec;
+ printf("Input #minutes:#seconds ");
+ scanf("%d:%d", &min, &sec);
+ printf("\n");
+ 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);
+ fflush(stdout);
+ sleep(1);
+ }
+ printf("\n");
+ return 0;
+}