Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <pthread.h>
  3. #include <string.h>
  4. #include <strings.h>
  5.  
  6. struct test{
  7.  
  8. int guess;
  9.  
  10. };
  11.  
  12. void test(void *insane){
  13. struct test *point;
  14. bzero(&point,sizeof(point));
  15. point = (struct test *)insane;
  16.  
  17. int boing = point->guess;
  18.  
  19. printf("DEBUG INSIDE %d\n",boing);
  20.  
  21.  
  22. }
  23.  
  24.  
  25.  
  26. void (*bleah[5])(void *insane);
  27.  
  28. int main(){
  29.  
  30.  
  31.  
  32. struct test bla;
  33.  
  34. bla.guess = 0;
  35. pthread_t t[5];
  36. int i = 0;
  37. for (i = 0 ; i < 5 ; i++){
  38.  
  39. bleah[i] = test;
  40.  
  41.  
  42. //(*bleah[i]) ((void *)&bla);
  43.  
  44. bla.guess = i;
  45. printf("%d\n",bla.guess);
  46. pthread_create(&t[i],NULL,(void*)bleah[i],(void *)&bla);
  47.  
  48.  
  49. }
  50.  
  51.  
  52. for (i = 0 ; i < 5 ; i++){
  53.  
  54. pthread_join(t[i],NULL);
  55.  
  56.  
  57. }
  58.  
  59.  
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement