I want to read someinfo from a file, and write someinfo into the file; there will be redundancy info in the file, if the length of writted info less than the length of original file info.
workaround:
open with std::fstream::in
then
open with std::fstream::trunc
std::fstream fs(fileName, std::fstream::in | std::fstream::out); char cArray[256]; fs.getline(cArray,256); fs.close();
std::fstream fsw(fileName, std::fstream::trunc | std::fstream::out); //fs.seekg(std::ios_base::beg);
fsw.write(totalStr.c_str(), totalStr.size()); fsw.close();
|
阅读(1628) | 评论(0) | 转发(0) |