Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; //four diiferent messeges #define THREAD_COUNT 4 // array of messages const char *my_messages[4] = { English: Hello!, French: Bonjor, Spanish:

#include #include

using namespace std;

//four diiferent messeges #define THREAD_COUNT 4

// array of messages const char *my_messages[4] = { "English: Hello!", "French: Bonjor", "Spanish: Hola!", "German: Gutan Tag" }; void *routineName(void *arg) { // TODO: Add code that implements // the thread's functionality int *index = (int *)arg; cout << my_messages[*index] << endl; return 0; }

int main() { pthread_t id[THREAD_COUNT]; int rc; int i; int loc[] = { 0, 1, 2 , 3}; for ( i = 0 ; i < THREAD_COUNT ; i++ ) { rc = pthread_create(&id, NULL, routineName, NULL);

if (rc){ cout << "ERROR; return code from pthread_create() is " << rc << endl; return -1; } } // waiting for all threads to complete for ( i = 0; i < THREAD_COUNT ; i++) pthread_join( id[i], NULL ); pthread_exit(0); } pthreads_skeleton.cpp: In function int main(): pthreads_skeleton.cpp:49:52: error: cannot convert pthread_t (*)[4] {aka long unsigned int (*)[4]} to pthread_t* {aka long unsigned int*} for argument 1 to int pthread_create(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*) rc = pthread_create(&id, NULL, routineName, NULL); ^

I keep reciving this error and I dont quite understand what it wants or how to fix it. Im not the best at coding so id appericate any an all help with this error

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago