Re: c++ beginner on gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


HTH
-- 
Claudio

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux