-1
你好我正在一個項目中,我有學生他們的數字姓氏和一切,我想選擇一個學生的名字,並刪除關於學生的整個信息在案例3:我的代碼:`我不能從文本文件中刪除單行C++
case 3:{
int fNomer;
string ime;
string prezime;
string familiq;
string fakyltet;
string specialnost;
int grypa;
int kyrs;
string stud;
cout << "Stydenta koito iskate da iztriete";
cin >> stud;
ifstream file;
ofstream outfile;
file.open("Student.txt");
outfile.open("newM.txt");
while (getline(file, line))
{
if (line == deleteMovie){}
else { outfile << line << endl; }
}
outfile.close();
file.close();
outfile.close();
file.close();
remove("Students.txt");
rename("newM.txt", "Students.txt");
break;
}
你應該正確地格式化你的代碼。例如,在你的C++教科書中。 –
歡迎來到StackOverflow。 請參考[遊覽], 學習問好問題stackoverflow.com/help/how-to-ask, 做個[mcve]。一個MCVE應包括各種樣本輸入(說明所有方面)和期望的輸出。 如果您正在尋找調試代碼的幫助,請參閱https://ericlippert.com/2014/03/05/how-to-debug-small-programs/ MCVE將提供關於例如deleteMovie的信息。這可能是失敗機制的一部分。 – Yunnosch