Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

C++ passing function arguments to a thread

void randVals(int val, char* str, double dblval)
{
  cout << val << " " << str <<" " << dblval << endl;
}

/**************************************************/

char* str = "Hello World!";

thread thread1(randVals, 3, str, 7.7);

if (thread1.joinable())
{
thread1.join();
}
 
PREVIOUS NEXT
Tagged: #passing #function #arguments #thread
ADD COMMENT
Topic
Name
1+7 =