help, gcc, ?cout error?

Greg Wimpey greg.wimpey@waii*removetomail*.com.invalid
Mon Dec 13 10:01:00 GMT 1999


aka007@mail.com writes:

> 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 <iostream>
> using namespace std;
> 
> int main() {
>   cout << "hello";
>   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.
> 

Does your code really say "#include <iostream>"?  That should be
"#include <iostream.h>", unless GCC has some facility for automagically
tacking the ".h" onto the end of the file name.

Second, the command line "g++ -o a a.cpp" will put the compiled code
in a file called "a", not "a.out".  You'll only see output in "a.out" if
you don't give it an output file name with the "-o" flag.

Finally, you shouldn't expect to see "hello" in your compiler output.
Your compiler output will be the executable, not the output of the program.
You need to execute the code; then you'll see the output.  It should go
something like this:

% g++ -o a a.cpp
% ./a
hello %

(Note that the lack of a newline ("\n") in your string means that the 
prompt will appear on the same line as your output.)

-- 
Greg Wimpey
greg.wimpey@waii*removetomail*.com.invalid


More information about the Gcc-help mailing list