summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
+}