I need to let the user stop the cycle while it is still iterating/looping.
I want my program to show "sec" many times, until the user pauses it.
#include<stdio.h>
#include<time.h>
#include<conio.h>
#include<stdlib.h>
#define p printf
#define s scanf
int main(void)
{
int i,j;
time_t seconds;
do
{
i=seconds;
seconds=time(NULL);
j=seconds;
if(i!=j)
{
p("sec");
}
}while(j==j);
getchar();
return(0);
}
Using getch or scanf, will stop the cycle each time. Can some one help me? I was thinking that there might be some function that detects if a key is being pressed, but doesnt wait for it to be pressed to continue the cycle. Of course the j==j is to keep an infinite cycle.
OMG i founf the solution here: c programming check if key pressed without stopping program
If you want i cant post the fisnished program, its for a friend that wants to improve in gun shooting.