1

I'm creating a thread in C but it passes the reference instead the value.

  for (i=0; i<num_thread; i++){
  pthread_create(&thread[i], NULL, mou_oponent,(void *)&i);
}

int mou_oponent(void* ind) //THIS IS THE HEADER OF THE FUNCTION

I need the value not the reference, because I take the value of i in the thread but it is changed because the for increments it.

1 Answers1

0

in int mou_oponent(void* ind) you should copy to other memory by other variable, then you work on other variable instead ind. hope it's help

songoku1610
  • 1,576
  • 1
  • 13
  • 17