Create a digital stopwatch program in C which runs on linux base system.
keyboardhit() function simply stands for keyboard hit. After pressing a key it generates a signal and returns a non zero integer. In this, there are 4 loops, 1st loop for hours, 2nd for minutes, 3rd for seconds and 4th loop for maintaining the speed of seconds(3 loop). After running this program it wait for a keyboard start(s) key to be pressed and when key is pressed, it generates a signal. For storing a keyboard key there is a variable(c), if c is equal to p key then it calls the wait function. The thread is running in the background and we are waiting for the start key to be pressed. After pressing s key, the thread again jumps to thread_join function, if r key is pressed, then it jumps into reset label and all the loops are again starts with zeros, if s key is pressed it jumps into start label and if e key is pressed it calls the exit() function and program gets terminated.
To execute the program we use following command :
Input: Press a key : s -> start e -> exit r -> reset p -> pause Output :
- fgets() and gets() in C language
- Difference between while(1) and while(0) in C language
- kbhit in C language
- C Language Introduction
- Signals in C language
- Difference between Java and C language
- chdir() in C language with Examples
- Interesting facts about C Language
- Constants vs Variables in C language
- isupper() function in C Language
- isalnum() function in C Language
- lvalue and rvalue in C language
- How to use POSIX semaphores in C language
- isxdigit() function in C Language
- A C Programming Language Puzzle
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : pixahosod