title: How do I use the MinGW gdb debugger to debug a C++ program in Windows?
body: <p>I have looked for documentation on this and found nothing. I have MinGW installed and it works great. I just don't know how to use the debugger.</p>
  
  <p>Given some simple code, say in a file called "mycode.cpp":</p>
  
  <pre><code>int main()
  {
      int temp = 0;
  
      for (int i = 0; i &lt; 5; ++i)
          temp += i;
  
      return 0;
  }
  </code></pre>
  
  <p>...how would I debug this. What are the commands that I use to debug code with MinGW and GDB in windows? Can I step through the code via the command line like in Visual Studio? If so what commands do I use to do that?</p>
  
  <p>Are there any tutorials for using GDB out there? I couldn't find any, but if anyone could direct me to one that would be great too. I'm tired of writing tons of <code>std::cout</code> statements to debug complex code.</p>