title: delete heap after returning pointer
body: <p>I have a function as below </p>
  
  <pre><code>int* readFile(string InputPath)
  {
      int *myvar = new int[10]; //The file has 10 lines (Using heap)
  
      ifstream inFile;
  
      inFile.open(InputPath.c_str(), ios::in);
  
      if (inFile.fail())
      {
          cout &lt;&lt; "Error reading the input file ";
          cout &lt;&lt; InputPath &lt;&lt; ".";
          exit(0);
      }
      string fileLine;
  
      while (getline(inFile, fileLine))
      {
         myvar[i]=toint(fileLine); //will be converted to int!
      }
      ;
      inFile.close();
  
  
  
      return myvar;
  }:
  </code></pre>
  
  <p>How can I free the heap (myvar)?
  In general, what is the best method to return such array?</p>