Results 1 to 5 of 5

Thread: Unable to memcpy a buffer to a struct

  1. #1
    Join Date
    Oct 2012
    Posts
    27
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Unable to memcpy a buffer to a struct

    hi! i have a problem. i have given struct and i declare a pointer on that struct. i want to copy using MEMCPY the contents of the buffer to the struct but i encountered "MEMORY ACCESS ERROR" during my debugging.

    Can someone pls help me to solve this problem?

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Unable to memcpy a buffer to a struct

    Did you create an instance of this struct apart declaring a pointer to it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2012
    Posts
    27
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to memcpy a buffer to a struct

    I don't understand. Can you pls. post as sample code? by the way, i placed the struct on the base class. im not that familiar with this.

    Thanks!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Unable to memcpy a buffer to a struct

    Do you know the difference between the following two statements?

    Qt Code:
    1. somestruct *v1;
    2. somestruct v2;
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Oct 2012
    Posts
    27
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to memcpy a buffer to a struct

    yes! thanks wysota. i already solve it. i just removed all the declared const in the struct.

Similar Threads

  1. Replies: 2
    Last Post: 29th October 2012, 11:52
  2. Replies: 11
    Last Post: 3rd April 2012, 05:51
  3. Unable to initialize char [] var inside struct ....
    By tonnot in forum General Programming
    Replies: 1
    Last Post: 26th August 2011, 11:40
  4. Replies: 5
    Last Post: 23rd June 2011, 09:31
  5. unable to save QCStrings properly in a buffer
    By nass in forum Qt Programming
    Replies: 13
    Last Post: 15th November 2006, 21:49

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.