title: Pthreads compile not working
body: <p>I have written some code but it doesn't seem to work when I compile it. I am trying to run this in Ubuntu:</p>
  
  <pre><code>#include &lt;pthread.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;unistd.h&gt;
  
  char buffer[128];
  
  void *write_thread(void *args)
  {
      int count = *((int*)args);
      write(STDOUT_FILENO, buffer, count);
  
      pthread_exit(0);
  }
  
  void *toupper_thread(void *args)
  {
      int i;
      int count = *((int*)args);
      for(i = 0; i &lt; count; i++) {
          buffer[i] = toupper(buffer[i]);
      }
  
      pthread_t writeId;
      pthread_create(&amp;writeId, NULL, write_thread, &amp;count);
  
      pthread_join(writeId, NULL);
      pthread_exit(0);
  }
  
  void *read_thread(void *args)
  {
      int count = read(STDIN_FILENO, buffer, 128);
      pthread_t toupperId;
      pthread_create(&amp;toupperId, NULL, toupper_thread, &amp;count);
  
      pthread_join(toupperId, NULL);
      //buffer[count] = 0;
  
      pthread_exit(0);
  
  }
  
  int main()
  {
      pthread_t threadId;
      pthread_create(&amp;threadId, NULL, read_thread, NULL);
  
      pthread_join(threadId, NULL);
  }
  </code></pre>
  
  <p>and I get these errors when I try to compile it with <code>gcc -pthread prob41.c</code> or with <code>gcc prob41.c -lpthread</code>:</p>
  
  <pre><code>   prob41.c:1:21: error: pthread.h: No such file or directory
     prob41.c: In function ‘toupper_thread’:
     prob41.c:23: error: ‘pthread_t’ undeclared (first use in this function)
     prob41.c:23: error: (Each undeclared identifier is reported only once
     prob41.c:23: error: for each function it appears in.)
     prob41.c:23: error: expected ‘;’ before ‘writeId’
     prob41.c:24: error: ‘writeId’ undeclared (first use in this function)
     prob41.c: In function ‘read_thread’:
     prob41.c:33: error: ‘pthread_t’ undeclared (first use in this function)
     prob41.c:33: error: expected ‘;’ before ‘toupperId’
     prob41.c:34: error: ‘toupperId’ undeclared (first use in this function)
     prob41.c: In function ‘main’:
     prob41.c:45: error: ‘pthread_t’ undeclared (first use in this function)
     prob41.c:45: error: expected ‘;’ before ‘threadId’
     prob41.c:46: error: ‘threadId’ undeclared (first use in this function)
  </code></pre>
  
  <p>I don't know what I'm doing wrong.</p>