“ delay()”函数无法在Dev cpp中使用

问题描述 投票:0回答:1

我正在使用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中的错误

c++ delay
1个回答
0
投票

conio.h&dos.h不属于C标准。您可以在Borland编译器中使用它们。 Dev c ++正在使用GCC编译器。

尝试一下:

#include <windows.h>
int main(){
//Your code
Sleep(1000);
//Your code
return 0;
}
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.