Chào mọi người!
Em xem đi xem lại nhưng vẫn hiểu hiểu hơi mơ hồ, mong mọi người bỏ ít thời gian giải thích giúp em với ạ.
Em cảm ơn!
void update(string tenFile, string a, string b)
{
string x;
string temp;
temp = "E:/Project Nhom 5 - CTDL Sang T4/TaiKhoan/" + tenFile + ".dat";
const char* y = temp.c_str();
ifstream ifile (temp);
ofstream ofile ("temp.dat");
while (!ifile.eof())
{
getline(ifile,x);
if (x == a)
{
ofile << b << endl;
}
else
{
ofile << x << endl;
}
}
ifile.close();
ofile.close();
remove(y);
rename("temp.dat", y);
}