A Question in Threads - C language (not C++)

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef Hi, <br style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef
<br style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef
<span style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef I wrote the following code:<br style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef
<br style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef

<div style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef; margin:5px 20px 20px
<div style="font-size:11px; margin-bottom:2px Code:
<pre class="x_alt2" style="background-color:#f4f4f4; padding:6px; border:1px inset; width:640px; height:418px #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);
}[/code]

<br style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef
<span style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef Unfortunately, This code pass compilation, but it doesnt print anything on the screen. I was trying to
put a breakpint, and once I operate the debug mode (F5), the program breaks down. <br style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef
<br style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef
<span style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef What is the problem with this code?
<span style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef
<span style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef Thanks.
<span style="font-family:verdana,geneva,lucida,lucida grande,arial,helvetica,sans-serif; font-size:13px; line-height:normal; background-color:#efefef

View the full article
 
Back
Top