I am setting up my environment to run a C++ program on VSCode in Windows 10. I have MINGW installed and the path (C:\MinGW\bin) added to my environment variables. I have added the appropriate extensions in VSCode.
In my hello world program. It works just fine. However, when I open a file, nothing prints from anywhere in the entire program.
I am compiling like this:
g++ main.cpp -o main
And running the program like this:
./main test.txt
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
cout <<"Here\n";
ifstream file; //This is the line that causes no output
file.open(argv[1]);
return 0;
}
The file is not the problem. I have tried multiple file types like .txt and .csv.