title: Proper use of readline in order to display history
body: <p>I'm making a program that shoul act like a real terminal in linux (ubuntu).</p>
  
  <p>What I have is this:</p>
  
  <pre><code>int main(int argc, char *argv[]){
  
     char cmd[500];
  
     do{
         printf("$ &gt; ");
         fgets(cmd, 499, stdin);
         //executeCommands(cmd);
     }while(strcmp(cmd, "exit\n") != 0);
  
     return 0;
  }
  </code></pre>
  
  <p>What I want to do is: When I press the up key, it should show me what I typed before, and so on... If I press the up key 3 times, it should show me the 3rd latest command used, and so on for the bottom key.</p>
  
  <p>I am not that good with C, but I understood that there is a library readline, and a history one, but I don't know how to use them in order to accomplish this.</p>
  
  <p>Thanks in advance</p>