From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Barron To: help-gcc@gnu.org Subject: Re: help, gcc, ?cout error? Date: Sun, 12 Dec 1999 09:09:00 -0000 Message-id: <3853CDE3.331411D4@mindspring.com> References: <3852d685.22627268@usenet.nau.edu> <3852FC1C.1DFC5B1B@csuhayward.edu> <3853018b.33642768@usenet.nau.edu> X-SW-Source: 1999-12/msg00188.html Hi, Jesse. I pasted your code into a file called jesse.cpp on my system. Watch this: $ gcc jesse.cpp /tmp/ccyMXXQa.o: In function `main': /tmp/ccyMXXQa.o(.text+0x25): undefined reference to `cout' /tmp/ccyMXXQa.o(.text+0x2a): undefined reference to `ostream::operator<<(int)' collect2: ld returned 1 exit status $ g++ jesse.cpp $ a.out 5$ The problem is that cout and iostream.h are part of C++, but gcc only handles C. To compile C++ code, you need to invoke the compiler as g++. To get a newline on the end of your output, you might want to do cout << a << endl; hth... Tom aka007@mail.com wrote: > > i modified it a bit, here is the current version: > > UW PICO(tm) 2.9 File: a.cpp > ... From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Barron To: help-gcc@gnu.org Subject: Re: help, gcc, ?cout error? Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: <3853CDE3.331411D4@mindspring.com> References: <3852d685.22627268@usenet.nau.edu> <3852FC1C.1DFC5B1B@csuhayward.edu> <3853018b.33642768@usenet.nau.edu> X-SW-Source: 1999-12n/msg00188.html Message-ID: <19991231222400.RRp0UuHdqgyS29ihEK6tMR5Xd9m1DoEPfP_od1eGReg@z> Hi, Jesse. I pasted your code into a file called jesse.cpp on my system. Watch this: $ gcc jesse.cpp /tmp/ccyMXXQa.o: In function `main': /tmp/ccyMXXQa.o(.text+0x25): undefined reference to `cout' /tmp/ccyMXXQa.o(.text+0x2a): undefined reference to `ostream::operator<<(int)' collect2: ld returned 1 exit status $ g++ jesse.cpp $ a.out 5$ The problem is that cout and iostream.h are part of C++, but gcc only handles C. To compile C++ code, you need to invoke the compiler as g++. To get a newline on the end of your output, you might want to do cout << a << endl; hth... Tom aka007@mail.com wrote: > > i modified it a bit, here is the current version: > > UW PICO(tm) 2.9 File: a.cpp > ...