title: c++ system() function error
body: <pre><code> void getresult(char * ip){
  char * buf=new char[100];
  const char * c=new char[100];
  string cmd;
  cmd="ping ";
  cmd.append(ip);
  cmd.append(" &gt;pingresult.txt");
  c=cmd.c_str();
  system(c);
  }
  </code></pre>
  
  <p>when i run the program in vs2012,there is no problem ,and the process is below <img src="https://i.stack.imgur.com/VuGl0.png" alt="enter image description here"></p>
  
  <p>but when i run the ping.exe(my program name) in the Debug f，there's an error "This file is in use by another program, the process cannot access"。 And the process is below <img src="https://i.stack.imgur.com/fJgHI.png" alt="enter image description here"></p>
  
  <p>the txt is  called by explore.exe and occupied. </p>