
January 5th, 2013, 12:47 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 3
Time spent in forums: 13 m 59 sec
Reputation Power: 0
|
|
|
Creating a thread
Hi,
I wrote the following code:
Code:
#include <stdio.h>
#include <Windows.h>
void ThreadFunction (int* index)
{
(*index) = (*index)+1;
}
void main()
{
int index=0;
HANDLE ReadPicThread;
ReadPicThread=CreateThread( NULL, 0 /*use default stack size*/, (LPTHREAD_START_ROUTINE) ThreadFunction /* thread function*/,
&index /* argument to thread function */,0 ,NULL /* returns the thread identifier */ );
printf("%d", index);
CloseHandle(ReadPicThread);
}
Unfortunately, This code pass compilation, but it doesn't print anything on the screen. I was trying to put a breakpint, and once I operate the debug mode (F5), the program breaks down.
What is the problem ?
Last edited by MatanBarLev : January 5th, 2013 at 01:30 PM.
Reason: Rephrase
|