/*替换与删除二进制文件中的某些文件,并且输出新的文件*/ #include <iostream> #include <fstream> using namespace std; bool copy_binary_file(const char * szDestFile, const char * szOrigFile) { bool bRet = true; std::ofstream fout(szDestFile, std::ios::binary | std::ios::app); std::ifstream fin(szOrigFile, std::ios::binary); if (fin.bad()) { bRet = false; } else { int num = 0; while(!fin.eof()) { num += 100; char szBuf[100] = {0}; fin.read(szBuf, sizeof(char) * 100); if (fout.bad()) { bRet = false; break; } if(num < 1000000) fout.write(szBuf, sizeof(char) * 100); else { fout.write(szBuf, sizeof(char) * 90); } } } fin.close(); fout.close(); return bRet; } int main(void) { const char *src = "1512912380_1512912440"; const char *dst = "1512912380_1512912440.bbw"; copy_binary_file(dst,src); return 0; }
删除与替换二进制文件中的某些字节数
猜你喜欢
转载自blog.csdn.net/yang20141109/article/details/78915213
今日推荐
周排行