#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    India
    Posts
    8
    Rep Power
    0

    Question Problem running c++ program on linux(cout and string)


    I am unable to execute this simple c++ code.
    When I compile and execute it does not display anything.
    gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

    //aj.cpp

    #include <iostream.h>

    int main()
    { cout<<"hello";
    return 0;
    }

    I use following command to compile
    $ g++ -Wno-deprecated -o aj aj.cpp

    And exexute
    $ ./aj

    It does not display anything.
    In fact, I am facing similar problem of running larger programs that includes string manipulations.

    Please help.

    Thanks
  2. #2
  3. No Profile Picture
    Dinesh_P_V
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    India
    Posts
    259
    Rep Power
    0
    Try to redirect the output to a file and see its contents or try

    cout<<"hello\n";

    -Murugesan
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    India
    Posts
    8
    Rep Power
    0
    Oh, thanks.
    Cout worked out. ("\n") was required.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Flint, MI
    Posts
    328
    Rep Power
    12
    try instead of \n to use << endl
    it's a little more portable. This comes up for me because I port between windows and UNIX a lot.

IMN logo majestic logo threadwatch logo seochat tools logo