basic threading help

Daedalus031's Avatar, Join Date: Apr 2012
Newbie Member
I am very new to threading and am having a small problem i just can't find the solution for. I am wanting to print out the values of and args.delay inside the mythread function. however i am getting the error error "C2228: left of '.id' must have class/struct/union".
struct ThreadArgs{
  int id;
  int delay;
}args ;

void main(){
		unsigned __stdcall mythread(void *data);
		unsigned ThreadId;

		int x = 5; = 2;
		args.delay = 3;

		HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, mythread, &args, 0, &ThreadId);
		WaitForSingleObject(hThread, INFINITE);


unsigned __stdcall mythread(void *data)

		ThreadArgs *args = (ThreadArgs *) data;

		cout<<"hello world"<<endl;
		return 0;
Thanks in advance for any help

Last edited by shabbir; 6Apr2012 at 10:20.. Reason: Code blocks
xpi0t0s's Avatar, Join Date: Aug 2004
args is a pointer, so you must use args->id, not