Thread: Create struct on heap

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Registered User
    Join Date
    Nov 2016
    Posts
    84
    Quote Originally Posted by laserlight View Post
    The second is probably better: you can just take the address of the local variable at the end. No need to worry about unique_ptr and even think about memory management.
    I thought something like this:

    TestParms * testParmsPtr = &myStruct;

    Last question: For my second try, would my constructor set all parms to 0 (memset)? Is this correct how I did it?
    And do you know anything about MQ data types? I am not sure whether this would work:

    memcpy(myStruct.parm4, dataLength, sizeof(myStruct.parm4)); as the data type of dataLength is MQLONG (32-bit integer) and parm4 is char[8].
    Last edited by Joe1903; 11-05-2019 at 06:04 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Read file, Create struct 5x5 numbers
    By Leite33 in forum C Programming
    Replies: 3
    Last Post: 12-12-2015, 11:29 AM
  2. Create struct tm from user specified date
    By cunzlow in forum C Programming
    Replies: 4
    Last Post: 09-30-2009, 12:39 PM
  3. How to create a matrix in the heap....
    By Tyrant in forum C Programming
    Replies: 10
    Last Post: 12-02-2007, 11:10 PM
  4. Use struct to create a boolean type
    By skyglin in forum C Programming
    Replies: 6
    Last Post: 06-18-2003, 08:21 PM
  5. about arrays create within a struct~
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 04-26-2002, 04:21 AM

Tags for this Thread