title: Printing element of array prints name of array instead
body: <p>I am trying to write a simulated shell program, with a history command that prints the 10 most recent entries in the shell. The problem is that when the history command is used, instead of printing the line typed, the name of addToHistory's internal array argument, "history" is printed for every entry.</p>
  
  <p>Here is the code.</p>
  
  <pre><code>void addToHistory(char *line, char **history, int num) {
      // insert line into first element of history
      // move elements backward to make room
      if(num == 0) {
          history[0] = line;
      }
      else if (num &gt; 1 &amp;&amp; num &lt; HISTORY_BUFFER) {
          printf("%d", num);
          printf("\n");
          for(int i = num-1;i &gt; 0;i--) {
              history[i] = history[i-1];
          }
          history[0] = line;
      }
      else if (num &gt; HISTORY_BUFFER) {
          printf("%d", num);
          printf("\n");
          for(int i = HISTORY_BUFFER-1;i &gt; 0;i--) {
              history[i] = history[i-1];
      }
          history[0] = line;
      }
  }
  
  
  int main(void)
  {
      char *args[MAX_LINE/2 + 1];              /* command line arguments                 */
      char *history[HISTORY_BUFFER];
      char line[64];
      int  should_run = 1;                     /* flag to determine when to exit program */
      int  num = 0;
      while (should_run) {
          printf("osh&gt; ");
          fflush(stdout);
          gets(line);                          /*   read in the command line             */
          printf("\n");
          parse(line, args);                   // function for splitting input into seperate strings; works fine
          if (strcmp(args[0], "exit") == 0)  { /* is it an "exit"?                       */
              should_run = 0;                  /*   exit if it is                        */
          }
          else if (strcmp(args[0], "history") == 0) {
              if (num == 0) {
                  printf("No commands in history. Please enter a command and try again\n");
              }
              else if (num &lt; 10) {
                  for(int i = 0;i &lt; num;i++) {
                      printf("%d ", i);
                      printf(history[i]);
                      printf("\n");
                  }
              }
              else {
                  for(int i = 0;i &lt; 10;i++) {
                      printf("%d ", i);
                      printf(history[i]);
                      printf("\n");
                  }
              }
          }
          /* snip */
          else {
              addToHistory(line, history, num);
              num++;
              // executeProcess(args);
          }
      }
  }
  </code></pre>
  
  <p>The output produced after 10 entries is something like</p>
  
  <pre><code>osh&gt; history
  0 history
  1 history
  2 history
  3 history
  4 history
  5 history
  6 history
  7 history
  8 history
  9 history
  </code></pre>
  
  <p>where "history" should instead be whatever was typed into the shell at the time. After one entry the output is simply <code>0 history', so the behavior is present in all iterations of</code>addToProcess`.</p>