title: Can't add item to const char* vector? C++
body: <p>I have an issue where I need a vector of const char* but for some reason whenever I try adding something nothing happens. Here is the code sample in question.</p>
  
  <pre><code>std::vector&lt;const char*&gt; getArgsFromFile(char* arg) {
      std::ifstream argsFile(arg);
      std::vector&lt;const char*&gt; args;
      while (!argsFile.eof()) {
          std::string temp;
          argsFile &gt;&gt; temp;
          args.push_back(temp.c_str());
      }
      args.pop_back();
      return args;
  }
  </code></pre>
  
  <p>The strange part is if I make this change</p>
  
  <pre><code>std::vector&lt;const char*&gt; getArgsFromFile(char* arg) {
      std::ifstream argsFile(arg);
      std::vector&lt;const char*&gt; args;
      while (!argsFile.eof()) {
          std::string temp;
          argsFile &gt;&gt; temp;
          const char* x = "x";
          args.push_back(x);
      }
      args.pop_back();
      return args;
  }
  </code></pre>
  
  <p>It will add 'x' to the vector but I can't get the value of temp into the vector. Any thoughts? Help would be greatly appreciated. Thanks!</p>