fork(1) download
  1. #include <iostream>
  2. #include <pthread.h>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. void* foo(void *a)
  7. {
  8. const vector <int>& b = *(vector <int>*)a;
  9.  
  10. for(int i=0; i<b.size(); i++)
  11. {
  12. std::cout<<b[i];
  13. }
  14. return NULL;
  15. }
  16.  
  17. void bar(int x)
  18. {
  19. std::cout<<"bar";
  20. }
  21.  
  22. int main()
  23. {
  24. pthread_t thr;
  25. std::vector <int> a = {1,2,3};
  26. pthread_create(&thr, NULL, &foo, (void *)&a);
  27. pthread_join(thr,NULL);
  28. return 0;
  29. }
Success #stdin #stdout 0s 83648KB
stdin
Standard input is empty
stdout
123