| incognito (65) | |||
Following is the pseudo code I have created.
} Program doesn't give segmentation fault but I am not sure whether the method I have used is right. Also, I assume the pointer location of ptr is stored in first 4 or 8 (for 64 bits) bytes of "arr". If the method is right, then 1. How do I make sure the values are correctly copied? I mean how do I print out the actual values? 2. While retrieving data from the timer class, how I do get it back? Using same method, that is, find the pointer location first and then values or something else needs to be done? Thanks in advance. | |||
|
|
|||
| coder777 (2378) | ||||
sizeof(ptr) bytes of what ptr points to is stored in the array (which is likely the content of value (i.e. 5))This memcpy(time.arr,ptr,sizeof(*ptr)); copies the content of ptrThis
sampleIt's is certainly not recommended to copy a class type like that.
| ||||
|
|
||||
| theranga (54) | |
memcpy(time.arr,&ptr,sizeof(ptr)); should work
| |
|
|
|