Reputation: 11
int Number1 = 0;
int Number2 = 0;
UINT __stdcall StaffA(LPVOID);
UINT __stdcall StaffB(LPVOID);
int _tmain(int argc, char* argv[])
{
UINT Id;
HANDLE hd[2];
srand(GetTickCount());
hd[0] = (HANDLE)_beginthreadex(NULL, 0, StaffA, NULL, 0, &Id);
hd[1] = (HANDLE)_beginthreadex(NULL, 0, StaffA, NULL, 0, &Id);
WaitForMultipleObjects(2, hd, TRUE, INFINITE);
CloseHandle(hd[0]);
CloseHandle(hd[1]);
system("pause");
return 0;
}
UINT __stdcall StaffA(LPVOID)
{
while(Number1 < 100)
{
...
}
return 0;
}
UINT __stdcall StaffB(LPVOID)
{
while(Number1 < 100)
{
...
}
return 0;
}
But it said
error: parameter name omitted at "UINT __stdcall StaffA(LPVOID)" and "UINT __stdcall StaffB(LPVOID)".
I am not sure what the problem is.
Upvotes: 0
Views: 655
Reputation: 134396
The problem is in your function definition. LPVOID
is a data type, while mentioning the parameter list in function definition, you need to have a paramater of that type, something like
UINT __stdcall StaffA(LPVOID p1) // p1 is the parameter name,
// which you can use inside the function body
{
while(Number1 < 100)
{
...
}
return 0;
}
Same goes for the other function definition, too.
Upvotes: 3