How do I send in a std::string into my thread?
This is my code:
void* sendReminder(void*)
{
system("echo 'hello' >> buffer.txt");
}
int main()
{
string str1 = "somevalue";
pthread_t t1;
pthread_create(&t1, NULL, &sendReminder, NULL);
}
You pass the value in as a
void*in the last argument topthread_create. Inside the thread function, you cast thevoid*back to the type of the object that you passed in. In this case a string.