0
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
const int max = 100;
void main()
{
char output[max];
string a;
ofstream veiw("myfile.txt");
cout << "Enter name: ";
getline(cin, a);
veiw << a;
ifstream get("myfile.txt");
//it have to show line
get.getline(output, max);
cout << output << endl;
system("pause");
}
該文件仍然保持由'view'打開。嘗試用'get'再次打開它很可能會失敗。我不禁注意到你的代碼沒有執行任何錯誤檢查。 –