Results 1 to 5 of 5

Thread: Cout library - QtCreator programming question

  1. #1
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,705
    Distro
    Ubuntu Development Release

    Exclamation Cout library - QtCreator programming question

    Hi, i am (still ) a beginner in C++
    I need the library in which i can found the "cout"
    The tutorial I follow uses iostrem.h, however Qtcreator gives error "Library not found"
    Qt finds the library iostream (without the extension .h)
    but cout doesn't seem to be there - it gives error "`cout` was not declared in this scope"

    Any help?

  2. #2
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: Cout library - QtCreator programming question

    cout is part of the c++ standard library, it represents the standard output stream
    it is defined in the header iostream. iostream.h is deprecated, this means your tutorial is outdated!
    http://www.cplusplus.com/reference/iostream/cout/

    it lies in the namespace std as all other standard stuff
    so you have to call std::cout or put a using namespace std on top of your source file or a using std::cout in the scope where it is used
    Last edited by MadCow108; April 10th, 2010 at 07:49 PM.

  3. #3
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,705
    Distro
    Ubuntu Development Release

    Re: Cout library - QtCreator programming question

    hmm all seem to be alright but p, li { white-space: pre-wrap; } endl;
    is not recognized as it was with simple cout

  4. #4
    Join Date
    Oct 2008
    Beans
    68

    Re: Cout library - QtCreator programming question

    I know your mistake.
    If you are using QT4c++ and want to develop console appli

    cations, you have to create a new Console Project. Thats the only way you can do it.
    And you have to execute it on the terminal. I don't why it doesn't works
    You have to compile in QT, after that go to terminal. In terminal go to the directory where the project is and do the following commands.
    Code:
    qmake name of the project.pro
    the do this one
    Code:
    ./name of the project

  5. #5
    Join Date
    Feb 2007
    Location
    Tuxland
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Cout library - QtCreator programming question

    #include <iostream>
    using namespace std;
    int main()
    {
    cout << "blah blah" << endl;
    return 0;
    }

    - or -

    #include <iostream>

    int main()
    {
    std::cout << "blah blah" << std::endl;
    return 0;
    }
    Proud GNU/Linux zealot and lover of penguins
    "Value your freedom or you will lose it, teaches history." --Richard Stallman

Bookmarks

Posting Permissions

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