I'm trying to copy a structure to be read by another program.
Source program :
struct datas{
std::string key;
};
datas mystructure = datas();
std::string mychar = "mychar";// if length of char > 8, it doesn't get copied.
mystructure.key = mychar;
WriteToResources(param, 0, (BYTE*)&mystructure, sizeof(mystructure));
Destination program :
struct datas{
std::string key;
};
datas mystructure;
memcpy(&mystructure, pbindata, rsrcsize);
std::cout << (char*)mystructure.key.c_str();
When mychar's length is <= 8 it gets copied to the resource and is read fine by the destination program. However, if mychar's length is > 8 nothing gets copied.
Thank you for your time.