title: Passing int and string parameters to thread C++
body: <p>I'm using _beginthead() to start my thread.  I need to pass 3 parameters to the thread: a string and two ints.
  Here's what I have, and this by no means is the entire program, and I've taken some things out that have nothing to do with the problem (disregard the mistakes with main, because in my actual program main isn't actually main and it's just a regular function):</p>
  
  <pre><code>typedef struct ST
  {
      char *ip;
      int port;
      int dur;
  }thestruct;  
  
  void main(char **arg_p, int arg_count)
  {
      char *ip;
      int port, duration;
      ip = (char *)malloc(sizeof(char));
      ip = arg_p[0];
      port = atoi(arg_p[1]);
      duration = atoi(arg_p[2]);
  
      thestruct *st;
      st = (thestruct *)malloc(sizeof(thestruct));
      st-&gt;dur = duration;
      st-&gt;ip = (char *)malloc(sizeof(char));
      st-&gt;ip = ip;
      printf("ip: %s\n", st-&gt;ip);
      st-&gt;port = port;
  
      _beginthread((void(*)(void*))connect, 0, (void*)st);
  }
  
  void connect(thestruct *s)
  {
      Sleep(100);
      char *ip = static_cast&lt;char*&gt;(s-&gt;ip);
      int port = s-&gt;port;
      int dur = s-&gt;dur;
      printf("ip: %s\nport: %i\ndur: %i", ip, port, dur);
      _endthread();
  }
  </code></pre>
  
  <p>Everything is working great, except the string, ip, isn't getting passed correctly to the thread.  The first printf call prints out the ip perfectly, and then inside the thread, it prints "ip: " and it's blank after that.  Then it goes to a new line and prints out the port and duration perfectly.</p>
  
  <p>I've been researching this problem topic for awhile to no avail because most people only need to pass one string or something like that.  So all I can find from googling is people passing a single string and of course that works.</p>
  
  <p>I pass for example "127.0.0.1 1234 25".  Also, there doesn't seem to be any problem with my struct because like I said, the two integers work perfectly, and I'm not getting any errors on the string, it's just not being passed.</p>
  
  <p>So anyway, if anyone can shine some light on the topic, that'd be great.</p>