Hello to everyone,
I am having this problem with the following code:
typedef struct test
{
int i;
char c[50];
} testStruct;
int main()
{
char *pData;
testStruct t;
t.i = 5;
strcpy_s(t.c, 50*sizeof(char), "hello");
pData = (char *)malloc(sizeof(t));
memcpy(&pData, &t, sizeof(t));
testStruct a;
memcpy(&a, &pData, sizeof(t));
cout << a.i << ' ' << a.c << endl;
system("PAUSE");
return (0);
}
The problem occurs with the variable "pData", the moment the program returns.
Could someone, please, indicate to me what the problem to the above source code is?
Thanks a lot,
Erroneous Seth