Mail Archives: djgpp/1997/03/05/13:24:48
Dazzling Dazz wrote:
>
> Can Someone please tell me what is wrong with the following program.
> I try to compile it on djgpp but I get 'undeclared' or something error.
> Maybe I don't have the right iostream.h file?
> #include <iostream.h>
> main()
> {
> cout << "Hello, World";
> }
> Thanks in advance. - bardito AT aracnet DOT com
>
> +++++++++++++++++++++++++++
>
> wouldn't you have to declare main as a void or int? Like this:
>
> void main()
> {
> ...
> return;
> }
>
> OR
>
> int main()
> {
> ...
> return 0;
> }
>
> I've never used that compiler so this is probably wrong, sorry.
I havent used that compiler yet BUT i think i know whats wrong, first of
all, in most cmopilers main() defualts to int main(void) So by just
having the line main() chances are your compiler reads it as int main
(void) SO first off i would add the line return 0; to the end of your
file.... Copy this code and try to compile it....first...
#include <iostream.h>
int main(void)
{
cout << " Hello, World\n";
return 0;
}
If you get an undefined COUT when you compile... check the file
extention and see if its .cpp OR .c or .gxx or .c for unix. Djgpp if i
remember correctly is a c/c++ compiler so there verywell could me a
option to have it use either the .c or .cpp nameing system some
compilers like borland will automaticly figure it out for ya, but some
of the older version don't... if the above program doesnt work, and you
copy it excatly, then the problem lies in an internal switch that you
must change... < in borland if you have the nameings set wrong it will
POP you into the iostream.h file and you will be wondering <THere isnt
anything wrong> but that is what it is.... =) anyhow good luck with
it.... and take care....
Stardog AT serv DOT net
- Raw text -