On Tuesday, May 15, 2012 11:26:33 AM UTC+5:30, Philip Guenther wrote:
> On May 14, 8:52 pm, somenath <
somenath...@gmail.com> wrote:
> > I have the following program crashing.
> >
> > #include
>
> > #include <stdio.h>
> ...
> > int main (int argc, char *argv[])
> > {
> > pthread_t thread_id[2];
> > void *thread_result;
> > int status;
> > int i =0;
> > while ( i ++ <2) {
> > status = pthread_create (&thread_id[i], NULL, thread_routine,
> > NULL);
> > if (status != 0)
> > puts ( "Create thread");
> > }
>
> What values does 'i' have *inside* the loop? Where are the thread ids
> stored?
>
I got the problem. I am going one more in thread_id array.
So for the other question
"VAL of i = 0
============================
Why it is printing as VAL of i = 0. Shouldn't it be 1 ? "
Is it because of undefined behavior caused by the array out bound access as well ?
Thanks for the help.