Results 1 to 8 of 8

Thread: error in QTextStream cout(stdout)

  1. #1
    Join Date
    Apr 2009
    Location
    India
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default error in QTextStream cout(stdout)

    Hi,
    I am getting error in
    QTextStream cout(stdout);

    Though its getting complied but giving error while executing.

    http://cartan.cas.suffolk.edu/oopdoc...tfirstapp.html

    Can anyone help me how to correct it?

    Regards and Thanks,
    Kaushik
    Last edited by kaushik_acharya; 7th April 2009 at 13:49.

  2. #2
    Join Date
    Oct 2007
    Location
    Grenoble, France
    Posts
    80
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error in QTextStream cout(stdout)

    If you want someone to help you, provide more details. What's the error message? We can't just guess it.
    You have to run a level 3 diagnostic.

    Ashes to ashes, Qt to Qt ( wysota )

  3. #3
    Join Date
    Apr 2009
    Location
    India
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: error in QTextStream cout(stdout)

    Hi,
    First of all sorry for giving incomplete info about the error in my previous post.

    I am getting this error:

    "Unhandled exception at 0x7c918fea in qt_test.exe: 0xC0000005: Access violation writing location 0x00000010."

    when it reaches the line:
    QTextStream cout(stdout);

    and it stops in a file called _file.c
    in this line:
    EnterCriticalSection( &(((_FILEX *)pf)->lock) );
    inside the function
    void __cdecl _lock_file
    Last edited by kaushik_acharya; 8th April 2009 at 08:08. Reason: updated contents

  4. #4
    Join Date
    Apr 2009
    Location
    India
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: error in QTextStream cout(stdout)

    Hi,
    I had copied this code from the online book as it is. Has anyone tried running this code?

    Regards,
    Kaushik

  5. #5
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: error in QTextStream cout(stdout)

    Works for me in Linux
    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

  6. #6
    Join Date
    Dec 2008
    Location
    My spaceship needs repairs..so, I am stuck on beautiful earth
    Posts
    98
    Thanks
    25
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: error in QTextStream cout(stdout)

    Hi,
    the code's working fine in Linux.Am using Qt 4.4.3 on Fedora.
    Better to put the code here,then more people are likely to test it out and tell you if they get any errors or can make sense of the errors you got.

    fac1.cpp
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main (int argc, char* argv[])
    4. {
    5. QApplication app(argc, argv);
    6. QTextStream cout(stdout);
    7.  
    8. // Declarations of variables
    9. int answer = 0;
    10.  
    11. do {
    12. // local variables to the loop:
    13. int factArg = 0;
    14. int fact(1);
    15. factArg = QInputDialog::getInteger(0, "Factorial Calculator",
    16. "Factorial of:", 1);
    17. cout << "User entered: " << factArg << endl;
    18. int i=2;
    19. while (i <= factArg) {
    20. fact = fact * i;
    21. ++i;
    22. }
    23. QString response = QString("The factorial of %1 is %2.\n%3")
    24. .arg(factArg).arg(fact)
    25. .arg("Do you want to compute another factorial?");
    26. answer = QMessageBox::question(0, "Play again?", response,QMessageBox::Yes | QMessageBox::No);
    27. }
    28. while (answer == QMessageBox::Yes);
    29. return EXIT_SUCCESS;
    30. }
    To copy to clipboard, switch view to plain text mode 

    fac1.pro
    Qt Code:
    1. TEMPLATE = app
    2. SOURCES += fac1.cpp
    To copy to clipboard, switch view to plain text mode 
    If everything seems to be going well, you have obviously overlooked something.

  7. #7
    Join Date
    Dec 2008
    Location
    My spaceship needs repairs..so, I am stuck on beautiful earth
    Posts
    98
    Thanks
    25
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: error in QTextStream cout(stdout)

    http://lists.trolltech.com/qt-intere...ad00855-0.html
    ...check out this thread.It's a bit similar to your query and might give you some idea.
    HTH.
    If everything seems to be going well, you have obviously overlooked something.

  8. #8
    Join Date
    Apr 2009
    Location
    India
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: error in QTextStream cout(stdout)

    @rishiraj,
    This webpage tells about using the visual studio debugger. I am using that and that's how I pointed out the error.

    The program is running if i use std::cout instead of QTextStream cout
    Is this some problem with visual studio?

    Regards,
    Kaushik

Similar Threads

  1. when close QTextStream
    By mattia in forum Newbie
    Replies: 1
    Last Post: 24th November 2007, 13:17
  2. Create QTextStream
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 17th June 2007, 20:25

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.