| | |
passing params to CreateThread
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2006
Posts: 36
Reputation:
Solved Threads: 0
i have a bunch of data i want to pass to CreateThread. i created a struct as per the msdn documentation. here it is:
then i initialise the struct, again as per the msdn documentation:
i get a crash at pThreadRecvData->data.push_back('x').
can anyone help ?
thank you.
C++ Syntax (Toggle Plain Text)
typedef struct ThreadRecvData { std::list<char> data; Ogre::String addr; unsigned long port; } THREADRECVDATA, *PTHREADRECVDATA;
then i initialise the struct, again as per the msdn documentation:
C++ Syntax (Toggle Plain Text)
PTHREADRECVDATA pThreadRecvData; pThreadRecvData = (PTHREADRECVDATA) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(THREADRECVDATA)); pThreadRecvData->addr = "123"; pThreadRecvData->port = 123; pThreadRecvData->data.push_back('x');
i get a crash at pThreadRecvData->data.push_back('x').
can anyone help ?
thank you.
You probably can't use HeapAlloc() to allocate memory for pThreadRecvData because std::list allocated memory from the standard heap using new operator. Replace HeapAlloc() with new and retest.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Other Threads in the C++ Forum
- Previous Thread: problems with reading random access line from a file
- Next Thread: sudoku in c++
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






