Hi all,

I just started to work C++ in Dev C++ compiler before that i used Turbo C++ compiler when i try to compile a simple program in Dev C++ compiler . I'm getting error .

Here's the program

#include <iostream>
#include <conio.h>

int main ()
{
 cout << "Hello World";
 getch();
 return 0;
}

I'm getting following error .

implicit declaration of function `int getchar(...)'

Please tell me what the problem with that code .

Thanks in advance

Recommended Answers

All 7 Replies

Hi all,

I just started to work C++ in Dev C++ compiler before that i used Turbo C++ compiler when i try to compile a simple program in Dev C++ compiler . I'm getting error .

Here's the program

#include <iostream>
#include <conio.h>

int main ()
{
 cout << "Hello World";
 getch();
 return 0;
}

I'm getting following error .

implicit declaration of function `int getchar(...)'

Please tell me what the problem with that code .

Thanks in advance

Dev C++ doesn't know about #include < conio.h>
getch() is why conio.h is needed.
change getch for getchar and it will not complain. You do not need conio.h.

To pause use system("PAUSE");
and #include <stdlib.h>
Also try getchar(); instead of getch()
and #include <stdio.h>

try adding:
using namespace std;

Thanks Aia , m3an for your replies.

After including <stdio.h> for getchar function it worked .

Can u tell me where i can get these types of Compiler specific information ? I checked build-in help but it didn't .

you should not mix C and C++. In C++ use cin.ignore() to pause the program instread of C getchar(). And you don't need stdio.h either.

#include <iostream>
using namespace std;
int main ()
{ 
    cout << "Hello World"; 
    cin.ignore();
    return 0;
}

To pause use system("PAUSE");
and #include <stdlib.h>

No, do not use system("PAUSE") . Here's why

commented: Always helping people. +2

Thanks WaltP ...
system("PAUSE") <--- was a gr8 tip.

Thanks to all for your replies. I have learned many new things from your replies due to that simple doubt.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.