CreateThread with char array
How to pass a char* as an argument to CreateThread?
Code:
#include <windows.h>
#include <iostream>
using namespace std;
char * buf1 = "Hello World!";
DWORD WINAPI runThread(LPVOID arg)
{
char * buf2 = reinterpret_cast<char*>(arg);
cout << buf2 << "\n";
return 0;
}
int main()
{
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)runThread, (LPVOID)buf1, 0, 0);
return 0;
}
Re: CreateThread with char array
Quote:
Originally Posted by
MasterDucky
How to pass a char* as an argument to CreateThread?
Is it a question or a tip?
Re: CreateThread with char array
lol a question of course, seeing that the code doesnt work. :)
Re: CreateThread with char array
Your process, and its threads, die when main() returns. Get the thread handle and wait on it before returning from main().
gg
Re: CreateThread with char array
Of course... thank you Codeplug! :)