title: using a string variable to ping and save a file in C++
body: <pre><code>system( "ping www.google.com  &gt;  pingresult.txt") 
  </code></pre>
  
  <p>From this code can the string <code>"ping www.google.com"</code>  be taken from an <code>std::string</code> variable? For example:</p>
  
  <pre><code>string ipAddress;
  
  cout &lt;&lt; "Enter the ip address: ";
  cin &gt;&gt; ipAddress;
  
  string ip = "ping" + ipAddress;
  **system ("ip &gt; pingresult.txt");** //error here
  sytem("exit");
  </code></pre>