comparison quicktimer.c @ 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
comparison
equal deleted inserted replaced
0:ee518e7d265d 1:5725e5313328
1 // This program makes a quick timer 1 // Quicktimer by William King, makes a quick timer
2 // Im making this because I don't have internet
3 // to access bash documentation so you might
4 // as well make a good C program
5
6 2
7 #include <stdio.h> 3 #include <stdio.h>
8 #include <stdlib.h> 4 #include <stdlib.h>
9 #include <string.h> 5 #include <string.h>
10 //#include <unistd,h>
11 #include <stdbool.h> 6 #include <stdbool.h>
12 #include <time.h> 7 #include <time.h>
13 8
14 9
15 int main(int argc, char* argv[]){ 10 int main(int argc, char* argv[]){
16 //unsigned int timeleft; 11 //unsigned int timeleft;
17 if (argc != 1){ 12 if (argc == 1){
18 printf("QuickTimer by Vilyaem peepsoftgames.github.io thekenyaz@yandex.com\n Usage:\n quicktimer (unsigned int seconds)\n"); 13 printf("QuickTimer by Vilyaem peepsoftgames.github.io thekenyaz@yandex.com\n Usage:\n quicktimer (unsigned int seconds)\n");
19 return 1; 14 return 1;
20 } 15 }
16 if(clock == -1){
17 printf("Quicktimer does not have access to the time, clock_t clock is -1!\n");
18 return 2;
19 }
20 unsigned int timeleft = 60; //argv[1];
21 printf("Starting Quicktimer Ctrl-C to stop. Time left %d \n", timeleft);
21 22
22 unsigned int timeleft = argv[1]; 23 while (timeleft != 0){
24 timeleft -= 1; //clock()/CLOCKS_PER_SEC;
25 printf("Time left: %d\n", timeleft);
26 system("sleep 1"); // LORD!
23 27
28 }
29
30 printf("%d\n",&timeleft);
24 printf("Timer has finished, enjoy your day. Glory to the Father, the Son, and the Holy Spirit\n"); 31 printf("Timer has finished, enjoy your day. Glory to the Father, the Son, and the Holy Spirit\n");
25 32
26 } 33 }