title: Segmentation fault when calling destructor
body: <p>Hey guys I'm fairly new at C++ and this is for my term project. When I make an IPADDRESS object on the STACK, the main.cpp file will run until the deconstructer member is called for the IPADDRESS object. The first section runs just fine, and the second section returns the same output, just with the segmentation error.</p>
  <pre><code>// Main file
  #include &lt;bits/stdc++.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &quot;IPInfo.h&quot;
  
  using namespace std;
  
  // Function declaration of display()
  void displayInfo(IPADDRESS);
  
  int main(){
  
      const char* address = &quot;cbc.ca&quot;;
      const char* command = &quot;nslookup &quot;;
  
          char buf[256];
          strcpy(buf, command);
          strcat(buf, address);
  
          string* Info = new(nothrow) string[256]; // Allocate 256 bytes to this string
          *Info = system(buf); // Allocate the response from the command line to Info (which is on the heap)
      cout &lt;&lt; Info &lt;&lt; endl &lt;&lt; *Info &lt;&lt; endl &lt;&lt; &quot;===============================&quot; &lt;&lt; endl &lt;&lt; endl;
      delete[] Info;
  
      IPADDRESS test(&quot;cbc.ca&quot;);
  
      displayInfo(test);
  
  // Displays but never exits the program correctly
  
      return 0;
  }
  void displayInfo(IPADDRESS Website){
  
      string* displayBus;
      displayBus = Website.getInfo();
      cout &lt;&lt; displayBus;
  }
  </code></pre>
  <pre><code>// Header file
  #ifndef IPInfo_H
  #define IPInfo_H
  
  #include &lt;bits/stdc++.h&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  class IPADDRESS{
  private:
      const char* command = &quot;nslookup &quot;;
      string url;
      string info;
      string address;
      int searchFor(string locator); // Find a substring in the getInfo string
  
  public:
      string* getInfo(); // Using the system(&quot;nslookup&quot;) call, get the info (Will be allocated to heap)
      IPADDRESS(string website);
      ~IPADDRESS();
      string getIPAddress(); // Using searchFor() get rid of unneeded characters and dump the IPAddress to a string
      string getName(); // Also output the name
  
  };
  
  IPADDRESS::IPADDRESS(string website){
      url = website;
  }
  
  IPADDRESS::~IPADDRESS(){
  }
  #endif
  </code></pre>