I have a loop whose running time is really longe and I want to save my variables before the loop finishes if requested by the user, but I don't want to block (wait for user to answer), like I need a method to check after an iteration finishes if the user have enterd a spesific key (say 's') if yes then save if not then continue to the other iteration.

now this can't be done by _getch() of cin since both will wait for the user to input something (i.e. is the user didn't press anything the execution will halt on them) so is there a function or a trick to just see if the user entered anything without halting for an input?

if the idea is not clear tell me to clarify further

any help will be appriciated