-
November 23rd, 2010, 02:39 PM
#1
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;
}
-
November 23rd, 2010, 03:47 PM
#2
Re: CreateThread with char array
Originally Posted by MasterDucky
How to pass a char* as an argument to CreateThread?
Is it a question or a tip?
Victor Nijegorodov
-
November 23rd, 2010, 10:32 PM
#3
Re: CreateThread with char array
lol a question of course, seeing that the code doesnt work.
-
November 24th, 2010, 12:14 AM
#4
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
-
November 24th, 2010, 02:20 AM
#5
Re: CreateThread with char array
Of course... thank you Codeplug!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|