Results 1 to 5 of 5

Thread: Strange problem

Threaded View

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

    Default Re: Strange problem

    Qt Code:
    1. char *tmp=(char*)(txt.readLine().toStdString().c_str());
    2. tab[i]=tmp;
    To copy to clipboard, switch view to plain text mode 

    I'm not a C++ expert but I think you should not do things like this. c_str() will give you a pointer internal object's storage containing null terminated string.
    I'm not sure if the pointer you keep in tab[0] will be still valid when you are on next iteration after another
    Qt Code:
    1. txt.readLine().toStdString().c_str()
    To copy to clipboard, switch view to plain text mode 
    .

    Try what I wrote in a previous post - it's definitely more Qt-ish
    You have to run a level 3 diagnostic.

    Ashes to ashes, Qt to Qt ( wysota )

  2. The following user says thank you to calhal for this useful post:

    pavel (18th December 2009)

Similar Threads

  1. MySQL driver - Very strange problem. PLEASE HELP ME. Thanks.
    By diego in forum General Programming
    Replies: 15
    Last Post: 3rd March 2011, 01:33
  2. Replies: 7
    Last Post: 13th August 2009, 16:11
  3. Replies: 2
    Last Post: 2nd June 2009, 14:57
  4. MySQL driver - Very strange problem. PLEASE HELP ME. Thanks.
    By diego in forum Installation and Deployment
    Replies: 0
    Last Post: 2nd June 2009, 01:56
  5. strange problem passing a vector
    By mickey in forum General Programming
    Replies: 15
    Last Post: 22nd November 2007, 09:46

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
  •  
Qt is a trademark of The Qt Company.