我正在使用Dev Cpp 5.11,并且我尝试运行具有时间延迟的简单代码,但它给我的错误是未定义“ delay()”。
这是我的代码:
#include <iostream>
#include <dos.h> //for delay
#include <conio.h> //for getch()
using namespace std;
int main()
{
clrscr();
cout<<"3";
delay(1000);
cout<<"2";
delay(1000);
cout<<"1"<<endl;
delay(1000);
getch();
return 0;
}
我的猜测是,这可能是dev cpp中的错误
conio.h&dos.h不属于C标准。您可以在Borland编译器中使用它们。 Dev c ++正在使用GCC编译器。
尝试一下:
#include <windows.h>
int main(){
//Your code
Sleep(1000);
//Your code
return 0;
}