#include <windows.h>
#include <iostream>
#define MAX_THREADS 1
usingnamespace std;
DWORD WINAPI primenum(LPVOID);
int main(int argc, char *argv[])
{
DWORD ThreadId;
HANDLE ThreadHandle;
int num = 0;
cout<<"Enter a number and it will generate the prime numbers:"<<endl;
cin>>num;
ThreadHandle = CreateThread(NULL,0,primenum,&num,0,&ThreadId);
for(int i = 0; i < MAX_THREADS; i++) {
CloseHandle(ThreadHandle);
}
return 0;
}
DWORD WINAPI primenum(LPVOID n){
for(DWORD i = 1; i <= LPVOID; i++)//error line
{
if(DWORD(n) % 2 == 0)
{
cout<<i<<" is a prime number"<< endl;
}
}
return DWORD(n);
}
You'll need to cast the pointer to a pointer-to-int, then dereference it.
Yeah.......I have NO IDEA of how to even start doing that. Like i said,I am really,REALLY bad at programming.Im sorry that im being a pain.But can you be a bit more specific.I re-copied the program to at least show that i attempted at doing it.but still can you help me out?