I would like to execute a loop and exit this loop after let's say 2 minutes.
while(condition) {
// do stuff
// exit this loop after 2 minutes
}
Could someone recommend me the best way to do this ?
Based on the answers, here is what I did :
time_t futur = time(NULL) + 120;
while(condition) {
// do stuff
if(time(NULL) > futur) {
break;
}
}