c++ beginner on gcc

Claudio Bley bley@CS.uni-magdeburg.de
Tue Jul 27 10:57:00 GMT 2004

On Tue, Jul 27, 2004 at 11:27:45AM +0100, ramesh kumar wrote:
> I am just writing my first c++ program on gcc compiler
> and i am not able to compile it. this is the program i
> saved in
> #include<iostream.h>
> void main()
> {
>   cout<<"hi this is my first program";
> }

You should get a good introductory book on programming in standard C++.

Your code is not standard conformant and contains an error (that is what
the compiler already told you). It should read:

#include <iostream>   

int main() {
  std::cout << "hi, ...";

> i typed the command "gcc hi.cpp" 

GCC (the GNU Compiler Collection) contains several frontends for different
programming languages (C, C++, Fortran etc.). The frontend for C++ is called
"g++". In order to compile/link C++ code, you should just use it:

$ g++ hi.cpp

This will produce a file called "a.out". In order to run it, type

$ ./a.out
hi, ...

> and this is the message i got. i am not sure about the
> gcc compiler version number. i downloaded it recently
> from gnu's site.

Giving the -v switch to gcc/g++ on the command line usually prints such
useful information:

$ gcc -v 
gcc version 3.3.3


More information about the Gcc-help mailing list