Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use a const char for this: const char* my messages [4]fEnglish: Hello!, French: Bonjour!, Spanish: Hola!, German: Guten Tag! Note that you must use a

image text in transcribed
Use a const char for this: const char* my messages [4]f"English: Hello!", "French: Bonjour!", "Spanish: Hola!", "German: Guten Tag!" Note that you must use a character arrays just as shown here 4. Modify the program to define a pthread function called printMessage that is sent a single integer parameter, index (wrapped in a void*). The function prints the message stored in the location index of the array my messages. You will need to use an explicit type cast in the function to get the index value from the void* parameter. 5. Modify the main function to create as many threads as there are messages in the global array, instruct each thread to execute the function printMessage and pass each thread the index of a different location in the array as a parameter (this code will go between the comment that says "TODO: Modify according to assignment requirements" and the "if (rc)" check). So, each thread will essentially execute the same function, but will print a different message based on the parameter it receives. 6. Compile your program and run it several times. Note that the output of your program is likely to look garbled and may not always show the

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

77 Project management concepts and applications.

Answered: 1 week ago