title: String, debugging, and Segmentation Error goes hand in hand
body: <p>Hi I am doing this simple program</p>
  
  <pre><code> #include &lt;iostream&gt;
   #include &lt;string&gt;
  
   using namespace std;
  
   int main (){
  
        string hi("Hi how are you");
  
        for(int i = 0;i&lt;4;i++)
             cout&lt;&lt;hi&lt;&lt;endl;
  
        return 0;
   }
  </code></pre>
  
  <p>When I compiled it and run it, there were no issues, but when I try to debug it, every time the IDE program (Code::Block 16.01) steps in or out of <code>string hi("hi how are you")</code> it gives me a Segmentation Fault.</p>
  
  <p>I know SF is when the program tries to access a space of memory that it is not supposed to access, and I know string class is a C-Sytle string that allocates memory dynamically, and deletes them automatically when the program is finished, hence there should be no issue in memory management, so this code shouldn't be a problem.</p>
  
  <p>BUT in this code I don't understand why do I get a SF when I debug it. When I tried debugging it for the first time and stepped out of <code>hi</code>, there were no errors, but when I tried watching <code>hi</code>, it gave me a SF, and when I try to debug it again, and I steped into <code>string hi</code> I get S.F.</p>
  
  <p>Screenshot of the error FYI
  <a href="https://i.stack.imgur.com/hMWpF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hMWpF.jpg" alt="enter image description here"></a></p>