Error in simple "Hello World" program
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
parthiban
Junior Poster in Training
80 posts since Sep 2006
Reputation Points: 10
Solved Threads: 6
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.
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
Thanks Aia , m3an for your replies.
After including 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 .
parthiban
Junior Poster in Training
80 posts since Sep 2006
Reputation Points: 10
Solved Threads: 6
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;
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
To pause use system("PAUSE");
and #include
No, donot use system("PAUSE") . Here's why
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Thanks WaltP ...
system("PAUSE") <--- was a gr8 tip.
minigweek
Junior Poster in Training
68 posts since May 2007
Reputation Points: 97
Solved Threads: 5
Thanks to all for your replies. I have learned many new things from your replies due to that simple doubt.
parthiban
Junior Poster in Training
80 posts since Sep 2006
Reputation Points: 10
Solved Threads: 6