Originally Posted by
ulti-killer
How can I display the message in one second before the program ends?
How about just sleeping for a second before the program exits (returns from main())?
A portable programmer might use something along the lines of
Code:
#ifdef _WIN32
#include <windows.h>
void msleep(unsigned int ms) {
Sleep(ms);
}
#else
#ifndef BSD_SOURCE
#define BSD_SOURCE 1
#endif
#include <unistd.h>
void msleep(unsigned int ms) {
if (ms >= 1000U) sleep(ms / 1000U);
if (ms % 1000U) usleep(1000U * (ms % 1000U));
}
#endif
to define a more or less portable function msleep(), which takes the number of milliseconds (thousandths of a second) to sleep as a parameter.
Try that, adding msleep(1000); before your return 0; line.