This simply shows that pointers, in the wrong hands, can cause problems no matter what the compiler does. I don't want a "fool-proof language". I want a high-performance language with enough flexibility that I can do what I need to do without the compiler getting in the way. One can always revert to pascal of course. Or Java.Dann Corbit wrote:If you have pointers to objects in your struct, then you might have problems due to shallow copy.Robert Pope wrote:Does that work? I thought you could only do that with the simple types, like int.sje wrote:Since source and destination objects are both structs of the same type, why not use a direct assignment instead of memcpy()?Code: Select all
pline->leaf = *bd;
Do a web search for shallow copy deep copy if you are not sure what I mean.
memcpy() bug
Moderators: hgm, Rebel, chrisw
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL