title: creating ls command in c
body: <p>I'm trying to create ls command. First, the code is not working if I enter "ls", it's working only when I enter the full path. Second, it's not looping after the exevcp(). why?
  Thanks. </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;string.h&gt; 
  #include&lt;unistd.h&gt;
  
  int main(void){
  
   char *line;
   char *args[32]; 
  
   memset(args, 0, sizeof(args)); 
   while (1){
     line = (char*)malloc(1024); 
     printf("$ "); 
     fgets(line,1024,stdin); 
     args[0] = strtok(line, " "); 
     args[1] = strtok(NULL, " ");  
  
     execvp(args[0], args);
     perror("execvp");  
    }  
   } 
  </code></pre>