Program Language/C & C++
[C++] 파일 마지막에 문자 추가하기
야곰야곰+책벌레
2022. 5. 13. 08:53
728x90
반응형
fstream을 이용하여 간단하게 추가하기
bool file_util::append(string str)
{
findFile(getDirectory(s2w(_filepath)), true);
ofstream ofs;
ofs.open(_filepath, ios_base::app);
if (!ofs.is_open())
return false;
ofs << str.c_str() << endl;
ofs.close();
return true;
}
fstream을 cout과 같은 용법으로 사용할 수 있다는 사실을 처음 알게 됨. @_@
728x90
반응형