title: VScode debugging problem with images data in c++
body: <p>I am facing a problem with VScode debugger and till now I have searched and tried many things but unable to solve it! Please help</p>
  <p>The problem is ..</p>
  <p>When i run a simple program, which only loads the image and shows it detailed parameters such as width and height (rows and columns), it works fine and i get the parameters values, WITHOUT USING THE DEBUGGER</p>
  <p>but when i run it with the debugger, the program still executes successfully without giving any error in the end, but the values of parameters are messed up. All of the values such as (image width, height, channels) are zeros. I wonder why?</p>
  <p>my main.cpp looks like this</p>
  <pre><code>#include &lt;iostream&gt;
  #define STB_IMAGE_IMPLEMENTATION
  #include &quot;stb_image.h&quot;
  using namespace std;
  
  int main()
  {
      int width, height, channels;
      uint8_t *img;
      cout&lt;&lt;&quot;loading the image&quot;&lt;&lt;endl;
  
      img = stbi_load(&quot;backside1.jpg&quot;, &amp;width, &amp;height, &amp;channels, 3);
      stbi_image_free(img);
  
      cout&lt;&lt;width&lt;&lt;endl;
      cout&lt;&lt;&quot;end of the program&quot;&lt;&lt;endl;
      return 0;
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/nMrET.png" rel="nofollow noreferrer">output without using debugger</a></p>
  <p>my launch.json looks like this</p>
  <pre><code>{
      // Use IntelliSense to learn about possible attributes.
      // Hover to view descriptions of existing attributes.
      // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
      &quot;version&quot;: &quot;0.2.0&quot;,
      &quot;configurations&quot;: [
          {
              &quot;name&quot;: &quot;g++.exe - Build and debug active file&quot;,
              &quot;type&quot;: &quot;cppdbg&quot;,
              &quot;request&quot;: &quot;launch&quot;,
              &quot;program&quot;: &quot;${fileDirname}\\${fileBasenameNoExtension}.exe&quot;,
              &quot;args&quot;: [],
              &quot;stopAtEntry&quot;: false,
              &quot;cwd&quot;: &quot;D:\\installed_softwares\\mingw\\mingw64\\bin&quot;,
              &quot;environment&quot;: [],
              &quot;externalConsole&quot;: false,
              &quot;MIMode&quot;: &quot;gdb&quot;,
              &quot;miDebuggerPath&quot;: &quot;D:\\installed_softwares\\mingw\\mingw64\\bin\\gdb.exe&quot;,
              &quot;setupCommands&quot;: [
                  {
                      &quot;description&quot;: &quot;Enable pretty-printing for gdb&quot;,
                      &quot;text&quot;: &quot;-enable-pretty-printing&quot;,
                      &quot;ignoreFailures&quot;: true
                  }
              ],
              &quot;preLaunchTask&quot;: &quot;C/C++: g++.exe build active file&quot;
          }
      ]
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/7FPXy.png" rel="nofollow noreferrer">output with the debugger</a></p>
  <p>breakpoints are set inside the main file window!</p>
  <p>Please note these points</p>
  <ol>
  <li>the path of mingw64 bin is set inside the environmental variables</li>
  <li>i have tried the same thing on my linux OS, same problem there. or i am missing same thing there as well</li>
  <li>currently i am using the &quot;stb_image&quot; library, i have also tried it with the opencv in my linux os.</li>
  </ol>
  <p>I have already spent a lot of time solving it, need your help now!
  advance thanks, for giving your time!</p>