Since you have not shown any code, it is difficult for you to know exactly what you want, but here is a way to call a function that expects char as an argument in the stream. If you cannot change the function to convert the argument itself, you will need a trampoline function to sit in the middle to do this and call the actual function.
#include <Windows.h> #include <process.h> #include <iostream> void ActualThreadFunc(char c) { std::cout << "ActualThreadFunc got " << c << " as an argument\n"; } unsigned int __stdcall TrampolineFunc(void* args) { char c = *reinterpret_cast<char*>(args); std::cout << "Calling ActualThreadFunc(" << c << ")\n"; ActualThreadFunc(c); _endthreadex(0); return 0; } int main() { char c = '?'; unsigned int threadID = 0; std::cout << "Creating Suspended Thread...\n"; HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, &TrampolineFunc, &c, CREATE_SUSPENDED, &threadID); std::cout << "Starting Thread and Waiting...\n"; ResumeThread(hThread); WaitForSingleObject(hThread, INFINITE); CloseHandle(hThread); std::cout << "Thread Exited...\n"; return 0; }
source share