C++入門選手,學習線程時寫了一小段代碼,如下
```#include "stdafx.h"
#include
#include
using namespace std;
DWORD WINAPI Fun1(LPVOID lpParamter)
{
char* buf = (char *)lpParamter;
cout << int(buf) << endl;
Sleep(1000);
}
int main()
{
HANDLE hThread[2];
for (int i = 0; i < 2; i++) {
hThread[i] = CreateThread(NULL, 0, Fun1, (LPVOID)i, 0, NULL);
}
cout << "3" << endl;
Sleep(5000);
for (int i = 0; i < 2; i++) {
TerminateProcess(hThread[i],0);
CloseHandle(hThread[i]);
}
return 0;
}
在VS2015編譯時報錯,說“Fun1”: 必須返回一個值, 請問各位大神這是什麼意思?我這程序應該怎麼改?
DWORD WINAPI Fun1(LPVOID lpParamter)
{
char* buf = (char *)lpParamter;
cout << int(buf) << endl;
Sleep(1000);
return 0;
}