I'm having a small issue here, so I'm storing a char pointer ( rather an array ), in a void pointer as following:
char result[255];
CEVariable result_var(CEType::string, result);
Now the result_var is then passed on to my engine, stored as a pointer, the variable structure is then accessed later on: ( m_pData is a void*, pointing to the char array )
strcpy((char*)pVar->m_pData, "42");
But no data is written to it, and I'm sure it points to the result array, as I checked the addresses. Maybe I have gotten something wrong in my understanding of void pointers, but the following seems to work: ( Just testing )
char dest[255];
void*ptr = dest;
strcpy((char*)ptr, "asdsa");
std::cout << dest;
The result array turns into an unreadable format, most likely random memory. Maybe never written to. My question is what may the issue be?
EDIT: CEVariable::
class CEVariable
{
public:
CEVariable() {}
CEVariable(CEType t, void* mem)
{
m_Type = t;
m_pData = mem;
}
// Variable Type
CEType m_Type;
// Variable Data Ptr
void* m_pData;
};
The result does not go out of scope as all is executed in one function.
Thank you for your time.