Mercurial Hosting > quicktimer
changeset 1:5725e5313328
Almost functional, need to interpret arg correctly, also ugly system() usage
author | VilyaemKenyaz |
---|---|
date | Wed, 26 Jul 2023 03:18:00 -0400 |
parents | ee518e7d265d |
children | 0dbfb504309e |
files | c.sh quicktimer quicktimer.c |
diffstat | 3 files changed, 23 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/c.sh Wed Jul 26 02:38:08 2023 -0400 +++ b/c.sh Wed Jul 26 03:18:00 2023 -0400 @@ -1,3 +1,10 @@ #!/bin/sh #Complation script -tcc quicktimer.c -o quicktimer +clear +echo "Compiling." +rm quicktimer +gcc quicktimer.c -o quicktimer +echo "WITHOUT ARGS" +./quicktimer +echo "WITH ARGS" +./quicktimer 30
--- a/quicktimer.c Wed Jul 26 02:38:08 2023 -0400 +++ b/quicktimer.c Wed Jul 26 03:18:00 2023 -0400 @@ -1,26 +1,33 @@ -// This program makes a quick timer -// Im making this because I don't have internet -// to access bash documentation so you might -// as well make a good C program - +// Quicktimer by William King, makes a quick timer #include <stdio.h> #include <stdlib.h> #include <string.h> -//#include <unistd,h> #include <stdbool.h> #include <time.h> int main(int argc, char* argv[]){ //unsigned int timeleft; -if (argc != 1){ +if (argc == 1){ printf("QuickTimer by Vilyaem peepsoftgames.github.io thekenyaz@yandex.com\n Usage:\n quicktimer (unsigned int seconds)\n"); return 1; } +if(clock == -1){ +printf("Quicktimer does not have access to the time, clock_t clock is -1!\n"); +return 2; +} +unsigned int timeleft = 60; //argv[1]; +printf("Starting Quicktimer Ctrl-C to stop. Time left %d \n", timeleft); -unsigned int timeleft = argv[1]; +while (timeleft != 0){ +timeleft -= 1; //clock()/CLOCKS_PER_SEC; +printf("Time left: %d\n", timeleft); +system("sleep 1"); // LORD! +} + +printf("%d\n",&timeleft); printf("Timer has finished, enjoy your day. Glory to the Father, the Son, and the Holy Spirit\n"); }