title: Create simple shell in C with a "Set prompt" command
body: <pre><code>#include &lt;string.h&gt;
  #include &lt;errno.h&gt;
  
  #define MAX_LENGTH 1024
  #define SPACES " \t\r\n"
  
  int main(int argc, char *argv[]){
  char line[MAX_LENGTH];
  char *cmd;
  char *PROMPT = "SUPER SHELL!!";
  
  while(1){
      printf(PROMPT);
      if (!fgets(line, MAX_LENGTH, stdin)) break;
  
      //parse and execute commands
  
      if((cmd = strtok(line, SPACES))){
      // clean errors
      errno=0;
      if (strcmp(cmd, "quit") ==0){
      break;
      }
      else if(strcmp(line, "Set Prompt") == 0){
      char *arg = strtok(0, SPACES);
      if (!arg){
          fprintf(stderr, "You were missing a prompt. \n");
      }
      else {PROMPT =arg;
    }
      }
    else system(line);
    if(errno) perror ("Command failed. sorry");
    }
    return 0;
    }
  </code></pre>
  
  <p>I am writing a program in which I have to write my own shell in C.
  There must be two commands : quit, which quits the program, and Set Prompt which changes the prompt.
  For some reason quit works but Set prompt does not.
  How can I fix this?
  Thank you</p>