From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arthur Gold To: help-gcc@gnu.org Subject: Re: help, gcc, ?cout error? Date: Sun, 12 Dec 1999 19:56:00 -0000 Message-id: <38546E30.A45AE9D2@bga.com> References: <3852d685.22627268@usenet.nau.edu> <3852FC1C.1DFC5B1B@csuhayward.edu> <3853018b.33642768@usenet.nau.edu> <3853CDE3.331411D4@mindspring.com> <3853e4af.91799515@usenet.nau.edu> X-SW-Source: 1999-12/msg00198.html aka007@mail.com wrote: > > thanks for letting me know what the diff was with gcc vs g++... > > hope this is still valid here? anyhow, here is current version of my > "hello" program: > > UW PICO(tm) 2.9 File: a.cpp > > #include > using namespace std; > > int main() { > cout << "hello"; As stdout is bufferred (stdout being where 'cout' sends output) unless you terminate your output with a newline (either by saying cout << "hello\n" or cout << "hello" << endl) you won't see any output. HTH, --ag > return 0; > } > > using command g++ -o a a.cpp , then it "thinks" for a moment, but > creates no output on the telnet session screen. pico a.out reveals an > empty file, no "hello" in there at all... at least no error > messages. > > so, i'm not even really positive my school has g++, but it doesn't > create an error when i try it using g++, so i figure it is on the > system? how can i know for sure? i thought a simple "hello" program, > to confirm i'll be able to do some programming, but maybe not. > > any thoughts? > > Jesse > aka007@mail.com > > On Sun, 12 Dec 1999 10:31:31 -0600, Tom Barron > wrote: > > >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 > >> ... -- Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info) mailto:agold@bga.com or mailto:agold@cs.utexas.edu -- A: Look for a lawyer who speaks Aramaic...about trademark infringement. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arthur Gold To: help-gcc@gnu.org Subject: Re: help, gcc, ?cout error? Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: <38546E30.A45AE9D2@bga.com> References: <3852d685.22627268@usenet.nau.edu> <3852FC1C.1DFC5B1B@csuhayward.edu> <3853018b.33642768@usenet.nau.edu> <3853CDE3.331411D4@mindspring.com> <3853e4af.91799515@usenet.nau.edu> X-SW-Source: 1999-12n/msg00198.html Message-ID: <19991231222400.zB9JN70UkW8uG7BklqAjYJngLbRWYQAePF8mAFrFco0@z> aka007@mail.com wrote: > > thanks for letting me know what the diff was with gcc vs g++... > > hope this is still valid here? anyhow, here is current version of my > "hello" program: > > UW PICO(tm) 2.9 File: a.cpp > > #include > using namespace std; > > int main() { > cout << "hello"; As stdout is bufferred (stdout being where 'cout' sends output) unless you terminate your output with a newline (either by saying cout << "hello\n" or cout << "hello" << endl) you won't see any output. HTH, --ag > return 0; > } > > using command g++ -o a a.cpp , then it "thinks" for a moment, but > creates no output on the telnet session screen. pico a.out reveals an > empty file, no "hello" in there at all... at least no error > messages. > > so, i'm not even really positive my school has g++, but it doesn't > create an error when i try it using g++, so i figure it is on the > system? how can i know for sure? i thought a simple "hello" program, > to confirm i'll be able to do some programming, but maybe not. > > any thoughts? > > Jesse > aka007@mail.com > > On Sun, 12 Dec 1999 10:31:31 -0600, Tom Barron > wrote: > > >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 > >> ... -- Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info) mailto:agold@bga.com or mailto:agold@cs.utexas.edu -- A: Look for a lawyer who speaks Aramaic...about trademark infringement.