C++ 读取文件内容到指定类型的变量方法
如下所示: #include #include #include #include using namespace std; int main(){ cout << "input the file name: "; string file_name; cin >> file_name; cout << endl; // ifstream infile("1.txt"); ifstream infile(file_name.c_str()); s
如下所示: #include #include #include #include using namespace std; int main(){ cout << "input the file name: "; string file_name; cin >> file_name; cout << endl; // ifstream infile("1.txt"); ifstream infile(file_name.c_str()); s