Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #ifdef _WIN32
- #include <io.h>
- #include <dos.h>
- #include <windows.h>
- #endif
- #ifdef __unix__
- #include <unistd.h>
- #include <time.h>
- #endif
- int SecondsToSleep;
- int SecondsLeft;
- int ShowHelp;
- int main(int argc, char* argv[]){
- if(argc == 1){
- ShowHelp = 1;
- }else{
- SecondsLeft = atoi(argv[1]);
- if(SecondsLeft == 0){
- ShowHelp = 1;
- }else{
- printf("Counting down... ");
- fflush(stdout);
- while(SecondsLeft > 0){
- printf("%i.. ", SecondsLeft);
- fflush(stdout);
- #ifdef _WIN32
- Sleep(1000);
- #endif
- #ifdef __unix__
- sleep(1);
- #endif
- SecondsLeft = SecondsLeft - 1;
- }
- printf("\n");
- }
- }
- if(ShowHelp == 1){
- printf("Sleep Countdown v1.1 - Jaap-willem Dooge\n\n");
- printf(" SleepCD <seconds>\n\n");
- fflush(stdout);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment