If you want to just delay the closing of the window without having to actually press a button (getchar()
method), you can simply use the sleep()
method; it takes the amount of seconds you want to sleep as an argument.
#include <unistd.h>
// your code here
sleep(3); // sleep for 3 seconds
References: sleep() manual