Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8408601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:40:40+00:00 2026-06-09T23:40:40+00:00

How do I send in a std::string into my thread? This is my code:

  • 0

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);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:40:42+00:00Added an answer on June 9, 2026 at 11:40 pm

    You pass the value in as a void* in the last argument to pthread_create. Inside the thread function, you cast the void* back to the type of the object that you passed in. In this case a string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use boost::asio::buffer to send a message using void Send(const std::string& messageData) { socket.async_write(boost::asio::buffer(messageData),
#include <iostream> #include <string> using namespace std; void bubbleSort(int data[], int n); int main()
I have to format std::string with sprintf and send it into file stream. How
This is what i have: std::string GetBytesAsHEX(const char *arr, int arr_size) { BYTE ch
For my application, I need to be able to send an std::vector<std::string> over a
class IShaderParam{ public: std::string name_value; }; template<class TParam> class TShaderParam:public IShaderParam{ public: void (TShaderParam::*send_to_shader)(
I'm trying to send simple string commands to the Matlab engine. This is my
I have a client that sends me data using this function: void CServerRetrieve::Send(char *buf,
I'm working this source code: #include <string> #include <vector> #include <iostream> #include <istream> #include
I send to my sever this POST petition: name=pepito&friends=pep+mar And I notice what arrives

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.