0

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

6
Contributors
7
Replies
8
Views
9 Years
Discussion Span
Last Post by parthiban
Featured Replies
  • 1
    WaltP 2,905   9 Years Ago

    [QUOTE=m3an;365798]To pause use system("PAUSE"); and #include <stdlib.h>[/quote] No, do [B]not[/B] use [INLINECODE]system("PAUSE")[/INLINECODE]. [url=http://www.gidnetwork.com/b-61.html]Here's why[/url] Read More

0

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.

0

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

try adding:
using namespace std;

0

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 .

0

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

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

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

Votes + Comments
Always helping people.
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.