hello!
I'm writing a C++ program and I have to use memcpy at some point.
I will explain my problem:
I have a simple struct named A and a class named B and I do the following:
Now,at some point of my program I have an object of type BCode:class B{ //private variables public: A* a1; void* pVoid; } A a2; a2=//assign a2 with a value
and memcpy works fine.
In another part of my program I have a pointer to an object of type BCode:B b1; memcpy((void*)((char*)b1.pVoid,(void*)&a2,sizeof(A));
as I call a function in which I send an object of type B like this:
function(&b1);
and when I get the results of memcpy it returns garbage or memory addresses,but not the value of a2 as it does above.So I think it must be pointer's fault..
Does anybody have any idea how to fix it?Code:function(B *b2){ memcpy((void*)((char*)b2->pVoid,(void*)&a2,sizeof(A));}



LinkBack URL
About LinkBacks



