run the process in a different thread. main thread will read the key stroke and increase the value from t from 0 to higher.
there is another function in stdlib that detect keystroke i cannot recall that function dont wait for key stroke...
void runningProcess()
{
while(1)
{
if(t==1) {
while(1)
{
if(t==2)
{
break;
}
}
}
else if(t==3)
{
return;
}
}
}