D
Darek Adamkiewicz
Hello folks
I hope code below will explain what I'm trying to achive.
It seems trivial/common but not for me at the moment
Help very apreciated.
Regards
Darek.
-----------------
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
typedef struct Test {
char name[128];
int count;
};
int test(Test *t);
int test(Test *t)
{
Test *loct = t;
t = (Test *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Test));
strcpy(t->name,"TestEntry");
t->count = 256;
//? so address of t has been changed, is there a way to assign struct
values to old one?
return 0;
}
int main()
{
Test *t;
char out[128];
test(t);
// Is there a way to get values passed to t?
// now of course printf statement doesnt print proper string value
printf("%s",t->name);
return 0;
}
I hope code below will explain what I'm trying to achive.
It seems trivial/common but not for me at the moment
Help very apreciated.
Regards
Darek.
-----------------
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
typedef struct Test {
char name[128];
int count;
};
int test(Test *t);
int test(Test *t)
{
Test *loct = t;
t = (Test *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Test));
strcpy(t->name,"TestEntry");
t->count = 256;
//? so address of t has been changed, is there a way to assign struct
values to old one?
return 0;
}
int main()
{
Test *t;
char out[128];
test(t);
// Is there a way to get values passed to t?
// now of course printf statement doesnt print proper string value
printf("%s",t->name);
return 0;
}