Hi everyone!
So, I'm trying to set a countdown timer with this code but everytime I run it I have to set the amount of seconds the countdown is going to go for. Instead of that I wanted to set the amount beforehand so when I run it the countdown would start automatically. Is there a way I can do that with this code?
Code:
#include <unistd.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main()
{
int iCounter;
scanf ("%d", &iCounter);
while (iCounter !=0){
printf ("\n\t%d", iCounter);
iCounter --;
sleep (1);
system ("cls");
} printf("\nCount down timer has expired\n");
return 0;
}