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; }


Reply With Quote

Victor Nijegorodov

Bookmarks