I decided to learn C++ and use Sublime text build 4126 on latest macos version to build my code. I use the Build system C++ single file without any other configuration.
#include <iostream>
#include <fstream>
using namespace std;
int main() {
cout << "Please enter input file name: ";
string iname;
cin >> iname;
ifstream ist{iname};
}
When building this, sublime text outputs: “error: expected ‘;’ at end of declaration” yet all lines have ;.
Upon debugging, I noticed that if I change:
ifstream ist{name}
to
ifstream ist(name) code compiles. I don’t understand why since ifstream ist{iname} is valid syntax.