Ms vc ++ can use the sleep function of MFC, the parameter is millisecond.
The delay function must be written by yourself. It is not included in the compiler.
# Include <time. h> // header file
Time_t start_time, cur_time; // variable Declaration
Time (& start_time );
Do {time (& cur_time );
} While (cur_time-start_time) <3 );
The above 3 is 3 seconds later
It is easy to rewrite it into your own delay function:
# Include <time. h>
Void delay (INT Sec)
{
Time_t start_time, cur_time; // variable Declaration
Time (& start_time );
Do {time (& cur_time );
} While (cur_time-start_time) <Sec );
}
Call:
(Void) delay (5); // 5 seconds behind
Delay shorter than one second can be written as follows:
Clock_t start_time, cur_time;
Start_time = clock ();
While (clock ()-start_time) <3.0 * clocks_per_sec)
{
}
However, some compilers do not support clock.
We recommend Ms VC ++ MFC sleep (MS)