user12994514
user12994514

Reputation:

"delay()" Function not working not working in Dev cpp

I'm using Dev Cpp 5.11 and i'm trying to run a simple code with time delays but it gives me error that "delay()"is not defined.

Here's my code :

#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;
}

My guess is that this is probably a bug in dev cpp

Upvotes: 0

Views: 2667

Answers (1)

Mehdi Mostafavi
Mehdi Mostafavi

Reputation: 880

conio.h & dos.h is not part of the C standard. You can use them in Borland compilers. Dev c++ is using GCC compiler.

Try this:

#include <windows.h>
int main(){
//Your code
Sleep(1000);
//Your code
return 0;
}

Upvotes: 1

Related Questions