title: Assignment of specific char* array element setting all elements of array to that element - C++
body: <p>I'm writing code that inputs a file and reads in each word as a separate char* like this:</p>
  
  <pre><code>char label[8];
  char type[5];
  char value[6];
  
  
  while (!input.eof()) {
      input &gt;&gt; label;
      input &gt;&gt; type;
      input &gt;&gt; value;
      storeSymbols(label, type, value);
  }
  </code></pre>
  
  <p>Then I set it to an element of a char* array like so:</p>
  
  <pre><code>void storeSymbols(char* lab, char* type, char* val) {
      labels[symCount] = lab;
      types[symCount] = type;
      values[symCount] = val;
      symCount++;
  </code></pre>
  
  <p>}</p>
  
  <p>However, when I print out all of the elements of the char* array, all of the elements are the same as the last element retrieved from the file. For example, if there were three labels in the document, defined as "one", "two", and "three" then at the end of the first loop, the array will contain "one", the second time it will contain "two" and "two" and the third time it will contain "three" "three" and "three". It also loops through an extra time, adding the last element to the array another time, making it four "three" elements in the array. Does anyone have any idea why this is happening?</p>
  
  <p>I've also tested this where I convert value to an int and add it to an int array and it works fine.</p>