해결했습니다! 모두들 대단히 감사합니다. 내 날이되었습니다! (안녕하세요, 오전 4시)C++ 이진 파일을 다른 파일로 편집
이진 파일로 .dat 파일을 열고 다른 .dat 파일의 첫 번째 1840 16 진수 문자로 바꾼 프로그램을 C++로 작성하려고합니다. 첫 번째 .dat 파일의 나머지 16 진수 값은 동일하게 유지합니다. 나는 오늘 약 12 시간을 보냈으며 거의 성공하지 못했다. 저는 초급 프로그래머입니다. 한 학기 동안 C++ 과정을 수강 했으므로 스트림에 참여하지 못했습니다.
은 (는 파일 및 모든 열리지 만 새 값을 추가 한 후 모든 것을 삭제)
어떤 도움을 크게 감상 할 수#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cmath>
#include <cstring>
using namespace std;
int main(){
string filename;
long size;
char* memblock;
cout << " Enter a file to be modded by Mod.dat ";
cin >> filename;
ofstream infile (filename ,std::ofstream::binary);
//filename: the file that will be opened and changed)
ifstream modFile ("Mod.dat", ifstream::binary);
// (mod.dat is the file that i get the first 1840 hex values from)
modFile.seekg (0,modFile.end);
size = modFile.tellg();
memblock = new char [size];
modFile.seekg (0, ios::beg);
modFile.read (memblock, size);
infile.write(memblock, 1840);
modFile.close();
infile.close();
cout << endl;
return 0;
}
, 나는이 작업을 수행하는 몇 가지 간단한 방법이 희망을.
해결! 모두들 대단히 감사합니다. 내 일이 이루어지고있다 (물론 아침의 오전 4시)
당신의 어딘가에서 당신의 memblock을 삭제 하시길 바랍니다. – doctorlove