hi,
I am new to multithreading in c++. i found a simple code on a site . i think i understood the essentials of multithreading after reading it but when i try to compile the source code which is :-
#include <windows.h> <WINDOWS.H>
#include <strsafe.h> <STRSAFE.H>
#include <stdio.h><STDIO.H>
#define BUF_SIZE 255
//------------------------------------------
// A function to Display the message
// indicating in which tread we are
//------------------------------------------
void DisplayMessage (HANDLE hScreen,
char *ThreadName, int Data, int Count)
{
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\jolly\Documents\Visual Studio 2010\Projects\learning windows programming\Debug\learning windows programming.exe : fatal error LNK1120: 1 unresolved externals
i am using visual studio 2010.
What is wrong ???
Please help me.
Thanks in advance for any assistance offered.
@kbw :thanks for your help . But after changing to console I was getting this error message that
msg not initialized ( It is in DisplayMessage function .)
Since i am new I did not knew how to initialize it so i simply gave it 0 then also there were some run time errors.
What to do ??
@Computergeek01
Hi ,
yes i do realize that this is not a good example but i am farely new so i was ready to take up any example just so that it works.
For instance i had read that we should not use CreateThread instead _beginthread etc, but beginthread was not there in visual studio and i did not knew it's equivalent in it .
I would be very thankful if u help me in using MULTITHREADING.
@ computerquip: This is sort of a repost. I guess they made some changes and are giving it another go. I had made some comments because the code doesn't hold on to the Handles for the new threads nor does it actually wait for the threads to finish before exiting, instead it creates blank handles and then waits for them to exit? I honestly don't know WTF the author was thinking
@ OP: Do you know how to use a call back function? I recently made a class that may help you out if you're interested in seeing how simple threading can be.