title: How to use read function to read from terminal input (stdin)?
body: <p>The main function will be in an infinite loop reading the numbers that the user puts in the terminal and storing them on a buffer. My problem is that I need to read from terminal using this function:</p>
  
  <p><code>read(int fd, void *buf, size_t count);</code></p>
  
  <p>How can the file descriptor point to the terminal?! (I hope I'm not saying some barbarity)</p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT: I already took your advice, but something is missing. This is a small program that I wrote to test:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  
  int buffer[5], i=0, j;
  
  int main(){
     for(j=0; j&lt;5; j++) buffer[j] = 0;
     while(i&lt;5){
       read(STDIN_FILENO, buffer, 8);
       printf("-&gt;%d\n", buffer[i]);
       i++;
     }
     return 0;
  }
  </code></pre>
  
  <p>Outup:</p>
  
  <pre><code>1
  -&gt;2609
  2
  -&gt;0
  3
  -&gt;0
  4
  -&gt;0
  5
  -&gt;0
  </code></pre>
  
  <p>Why this doesn't print the numbers that I inserted?</p>