Find the answer to your Linux question:
Results 1 to 5 of 5
I'm doing my first steps in C++, bought a book called C++ for Linux, but I have problems in the very first progtam the "Hello world!". Of course I wanted ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Enthusiast minthaka's Avatar
    Join Date
    May 2006
    Location
    Mol, Vojvodina
    Posts
    556

    Where is iostream.h ?


    I'm doing my first steps in C++, bought a book called C++ for Linux, but I have problems in the very first progtam the "Hello world!". Of course I wanted to compile it with gcc try.c -o try , but it answered me it cannot find iostream.h included in the source code. I'm using gcc-4.1. What's wrong ?
    If you need a CD/DVD catalogizer, give a try to my program:
    http://www.kde-apps.org/content/show...content=100682
    Linux Usert#430188

  2. #2
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    Post your code. Did you remember to add using namespace std; at the top right after your header declarations?
    Registered Linux user #270181
    TechieMoe's Tech Rants

  3. #3
    Linux Enthusiast minthaka's Avatar
    Join Date
    May 2006
    Location
    Mol, Vojvodina
    Posts
    556
    #include <iostream.h>;
    using namespace std;
    int main(){
    cout << "Hello world !\n";
    return 0;
    }

    ERROR>
    Try.c:1:23: error: iostream.h: No such file or directory
    If you need a CD/DVD catalogizer, give a try to my program:
    http://www.kde-apps.org/content/show...content=100682
    Linux Usert#430188

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    Quote Originally Posted by minthaka View Post
    #include <iostream.h>;
    using namespace std;
    int main(){
    cout << "Hello world !\n";
    return 0;
    }

    ERROR>
    Try.c:1:23: error: iostream.h: No such file or directory
    You need to decide whether you want to write this in C or C++. You're mixing two different coding styles and compiling it with gcc. In ANSI standard C++, you do not put the .h after your header declarations. Also, cout is a C++ statement that will not be understood by the gcc compiler. Here is what I would try:

    Code:
    #include <iostream>;
    using namespace std;
    
    int main(){
           cout << "Hello world !\n";
           return 0;
    }
    Save it as a .cpp file and compile it with this:

    Code:
    g++ try.cpp -o try
    Registered Linux user #270181
    TechieMoe's Tech Rants

  6. #5
    Just Joined!
    Join Date
    Jul 2008
    Posts
    1

    Talking

    Quote Originally Posted by techieMoe View Post
    You need to decide whether you want to write this in C or C++. You're mixing two different coding styles and compiling it with gcc. In ANSI standard C++, you do not put the .h after your header declarations. Also, cout is a C++ statement that will not be understood by the gcc compiler. Here is what I would try:

    Code:
    #include <iostream>;
    using namespace std;
    
    int main(){
           cout << "Hello world !\n";
           return 0;
    }
    Save it as a .cpp file and compile it with this:

    Code:
    g++ try.cpp -o try
    LOL

    Easy mate.

    Nobody has born knowing these tricks!!!!.

    In a windows compiler, it would run perfect!!!!
    but as you know windows is a !@(*&#!(@*&#(!@*#& dam place to improve programming skills!

    This guy is starting good!!!! starting in POSIX life!!!!

    completing...

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main(){
           cout << "Hello world !\n";
           return 0;
    }
    DAMMM MAN!!! you must to decide wheter language you want to USE!!!!!

    Save it as a .cpp file and compile it with this:

    Code:
    g++ try.cpp -o try
    LOL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •