title: Strange behavior in C++, cout statement is required to prevent app crash?
body: <p>I am attempting to solve an algorithm problem but am witnessing strange behavior. Whenever I comment out the first cout statement as it seemed relatively benign and only there for testing purposes my script does not run. It will compile without errors but when I run with a txt file input parameter it crashes.</p>
  
  <p>However, if I leave the cout statement in the script below it runs fine with no problems. I am not sure why this is happening. Again the script works but not as intended when commenting out a seemingly non-essential cout statement. What am I missing here?</p>
  
  <p><strong>Test input file</strong></p>
  
  <pre><code>5
  9 6
  4 6 8 
  0 7 1 5
  </code></pre>
  
  <p><br></p>
  
  <pre><code>int main(int argc, char *argv[]) 
  {
      ifstream stream(argv[1]);
      string line;
      while (getline(stream, line)) 
      {
  
          cout&lt;&lt;line&lt;&lt;" String representation."&lt;&lt;endl;  // Why do i need to keep this to prevent segfault / AppCrash (windows)?
          vector&lt;long int&gt; numbers = string_to_ints(line);
  
          for (int i =0; i &lt; numbers.size(); i++)
          {
              cout&lt;&lt;numbers.at(i)&lt;&lt;" ";
          }
          cout&lt;&lt;" number representation."&lt;&lt;endl;
  
      }
      return 0;
  } 
  </code></pre>
  
  <p>string_to_ints() declaration below</p>
  
  <pre><code>vector&lt;long int&gt; string_to_ints(string input) // takes string input and produces a list of ints
  {
  
      char* buffer;
  
      stringstream ss(input);
  
      vector&lt;long int&gt; tokens;
  
      while (ss &gt;&gt; buffer)
      {
          tokens.push_back(atol(buffer)); // creates a vector of ints
      }
  
      return tokens;
  }
  </code></pre>
  
  <p>I am using gcc version 4.8.1</p>