i want to run a user specified number of threads however i get the following errors:Code:#include <pthread.h> #incldue <stdlib.h> #include <cstdio.h> #include <calloc.h> void *testing(void *threadid) { printf("hello"); pthread_exit(NULL); } int main() { int c=5; pthread_t *thread1; thread1 = (pthread_t*)calloc(c, sizeof(pthread_t)); pthread_create(thread1[0], NULL, testing, NULL); pthread_create(thread1[1], NULL, testing, NULL); pthread_create(thread1[2], NULL, testing, NULL); pthread_create(thread1[3], NULL, testing, NULL); pthread_create(thread1[4], NULL, testing, NULL); return 0; int x=0; for(x; x<c; x++) { pthread_join(thread1[t],NULL); } return 0; }
main.cc:9: error: `printf' undeclared (first use this function)
main.cc:9: error: (Each undeclared identifier is reported only once for each
function it appears in.)
main.cc: In function `int main()':
main.cc:18: error: `calloc' undeclared (first use this function)
main.cc:19: error: cannot convert `__pthread_st*' to `__pthread_st**' for
argument `1' to `int pthread_create(__pthread_st**, const pthread_attr_t*,
void*(*)(void*), void*)'
main.cc:20: error: cannot convert `__pthread_st*' to `__pthread_st**' for
argument `1' to `int pthread_create(__pthread_st**, const pthread_attr_t*,
void*(*)(void*), void*)'
main.cc:21: error: cannot convert `__pthread_st*' to `__pthread_st**' for
argument `1' to `int pthread_create(__pthread_st**, const pthread_attr_t*,
void*(*)(void*), void*)'
main.cc:22: error: cannot convert `__pthread_st*' to `__pthread_st**' for
argument `1' to `int pthread_create(__pthread_st**, const pthread_attr_t*,
void*(*)(void*), void*)'
main.cc:23: error: cannot convert `__pthread_st*' to `__pthread_st**' for
argument `1' to `int pthread_create(__pthread_st**, const pthread_attr_t*,
void*(*)(void*), void*)'
main.cc:28: error: `t' undeclared (first use this function)