How can I add a time delay before the exit command in C/C++?

  • Context: C/C++ 
  • Thread starter Thread starter Akshay_Anti
  • Start date Start date
  • Tags Tags
    Delay
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
Akshay_Anti
Messages
62
Reaction score
0
Hello! I was writing a basic program and was wondering about this problem:-

when i give exit(0); the compiler exits as soon as that part of code is reached. Is there any piece of code such that after it reaches that part of code, it waits for some time before executing exit command? This can be used in case when upon exit, a message is to be displayed.

Thank you in advance
 
Physics news on Phys.org
In your program you could include code just before the exit(0) to display a message to indicate the user should press the enter key, then wait for user input.