问题
The delay function of dos.h
header file does not work in codeblocks. It shows that delay function is undeclared.
the following link contains the program below.
link
int main ()
{
printf ( " This c program will exit in 10 seconds.\n");
delay(10000);
return 0;
}
回答1:
I was also having same problem & I used this function
#include <time.h>
void delay(int milliseconds)
{
long pause;
clock_t now,then;
pause = milliseconds*(CLOCKS_PER_SEC/1000);
now = then = clock();
while( (now-then) < pause )
now = clock();
}
edited :
As commented, this does make system busy. I have fund better way to do it, and works for CodeBlocks.
#include <windows.h>
.
.
.
Sleep(100); //sleep for 0.1 second
.
回答2:
i think it only works on turbo c. It is a Borland specific and works in turbo c compiler.
see link
来源:https://stackoverflow.com/questions/28128825/does-dos-h-header-file-work-in-codeblocks