title: C++ System command outputs 0 at end
body: <p>So I am writing a C++ program that runs a command within the program. Whenever I do run the command though, it outputs a 0 at the end of whatever its supposed to output. Example:</p>
  
  <pre><code>The random int I was thinking of was 130
  </code></pre>
  
  <p>Where it is only supposed to output <code>The random int I was thinking of was 13</code> but it still outputs the 0 at the end. Here is my code to run the command:</p>
  
  <pre><code>printf("Running file: %s\n", fileName);
  if(!exists(fileName))
  {
      printf("That file does not exist.\n");
      return;
  }
  char buffer [7+strlen(fileName)];
  int n;
  n = sprintf(buffer, "php -f %s", fileName);
  cout &lt;&lt; system(buffer) &lt;&lt; endl;
  </code></pre>
  
  <p>I dont think it has anything to do with the <code>php</code> command, because whenever I type into my terminal, <code>php -f &lt;filenamehere&gt;</code> it comes out with the <code>The random int I was thinking of was 13</code> output. I cannot think of anything else.</p>