Debugging in Visual Studio Code not reading from file

  c++, visual-studio-code

I’m new to Visual Studio Code, I’ve managed to set up the debugger with mingw but reading from files doesn’t work. While running the executable it reads correctly from the file and displays the correct answer but when debugging it always displays 0.

#include <iostream>
#include <fstream>

using namespace std;
ifstream f("data.in");

int main()
{
    int n;
    f>>n;
    cout<<n;
}

Source: Windows Questions C++

LEAVE A COMMENT