title: C pthread_create
body: <pre><code>typedef struct client
  {
     pthread thread;
     Window_t *win
  }client;
  
  client * client_create(int ID)
  {
      client *new_Client = (client *) malloc(sizeof(client));
      char title[16];
  
      if (!new_Client) return NULL;
  
      sprintf(title, "Client %d", ID);
  
      /* Creates a window and set up a communication channel with it */
      if ((new_Client-&gt;win = window_create(title))) 
          return new_Client;
      else {
          free(new_Client);
          return NULL;
      }
  }
  </code></pre>
  
  <p>When the user inputs 'e' I try to create a new thread with a new client and window by doing this is my int_main.
  The flag is just to tell me that the user entered e</p>
  
  <pre><code>if(eflag == 1)
  {    
      client *c = NULL;
      c=client_create(started);
      pthread_create(&amp;c.thread, NULL, client_create, (void *) &amp;started);
      started++;
      eflag =0;
  }
  </code></pre>
  
  <p>This is supposed to create a new client on a new thread on a new window but it doesn't do that. </p>
  
  <p>I'm not sure what to put in my pthread_create, and also how am I supposed get a new instance of client, because the client_create function creates a new window. And when I try to create a new thread by doing pthread_create it also creates a new window... If this was java oeverytime the user pressed 'e' I would just create a new instance of the class client... but I can't really do that here. any suggestions? </p>