誰かがこのプログラムの何が問題なのか教えてください。ここで子プロセスを作成して、シェルのような機能を実装しようとしています。lsorのような単一の単語を含むコマンドを実行すると機能しますが、 orpwdのような複数の単語を含むコマンドは機能しません。私がやっているがデバッグできないばかげた間違いがあります。ls -lrtwho am i
    #include <stdio.h>
    #include <string.h>
    #include <unistd.h>
    #include <iostream>
    #include <wait.h>
    #include <errno.h>
    #include <sys/types.h>
    #include <cstdlib>
    #define BUFSIZE  200
    #define ARGVSIZE 40
    #define DELIM    "\n\t\r"
    int main ()
    {
      int i,n;
      char buf[BUFSIZE + 1] ;
      char * str = "Shell > ";
      char * clargs[ARGVSIZE] ;
      int returnstatus;
      for(;;)
      {
          n = 1;
          write(STDOUT_FILENO,str,strlen(str));
          read(STDIN_FILENO,buf,BUFSIZE);
          if(!strcmp(buf,"exit\n"))
          {
              perror("exit");
              exit(20);
          }
          clargs[0] = strtok(buf,DELIM);
          while((clargs[n] = strtok(NULL,DELIM)) != NULL)
              n++;
          clargs[n] = NULL;
          switch(fork())
          {
          case 0:
          if((execvp(clargs[0],&clargs[0])) < 0)
              exit(200);
          default:
          wait(&returnstatus);
          printf("Exit status of command : %d\n",WEXITSTATUS(returnstatus));
          for(int i =0; i <= n;i++)
              clargs[i] = "\0";
          for(int i =0; i < BUFSIZE+1;i++)
              buf[i] = '\0';
      }
  }
  return 0;
}