Hi!
This is the first time that i want to use threads, so i don't understand them fully for now.
I have two structures:
struct ddata //difference content
{
char *filename;
char *size;
};
struct ddata *difference = (struct ddata *) malloc( dif * sizeof *difference );
struct test
{
struct ddata* difference;
int diff;
};
struct test *MSG2;
MSG2 = (struct test*)malloc(sizeof(test));
MSG2->difference = difference;
MSG2->diff = diff;
I want to "send" the MSG2 two structure to my thread, and i did it this way:
CreateThread(
NULL, // default security attributes
0, // use default stack size
CopyThread, // thread function name
&MSG2, // argument to thread function
0, // use default creation flags
NULL);
And now, here comes my problem. In my thread, i cast pParam back, and i want to print out some data to test it, but i am getting random characters. My thread:
DWORD WINAPI CopyThread( LPVOID pParam )
{
char a[100];
test *Test = (test*)(pParam);
sprintf(a, "diff: %s", Test->difference->filename );
MessageBoxA(NULL,a,0,0);
}
What i am doing wrong?
Thanks in advance!
kampi