I was working on a piece of c++ and was trying to return a struct. The struct has two fields.
struct statusStoredString{
int status;
char* value;
};
and in a function later one
int randomFunction() {
return myStruct; //some mem address
}
//some code later on
structhing = randomFunction(); //different memory address.
However, when I return that struct, the memory addresses are different by exactly 0x110 every time. Also, the .status works fine, but only the char pointer returns gibberish which makes me think that it isnt doing a deep copy or something along those lines. Why does this occur?
Aucun commentaire:
Enregistrer un commentaire