title: usleep() function does not allow a loop to continue
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  
  int main(void)
  {
          int i=0;
          while(i&lt;10)
          {
                  printf("%d", i);
                  usleep(10000); // or sleep(1)
                  i++;
          }
          return 0;
  }
  </code></pre>
  
  <p>I want the program to last 10 secs, i.e. print 1 - wait 1 sec - print 2 - wait 1 sec and so on until the end. But it doesn't do that - it just  waits for all the time (10 secs) and then prints the whole array of numbers together without any time delays between them, it just prints 0123456789 at once. 
  EDIT: I tried with sleep() instead of usleep but it's the same 
  How to fix it ? And why it's like that ?</p>