Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / Solutions Sem. 03 / ex4 / source.cpp
blob: 60ea3e2b9c58fb7bee0d93587c83061916757d50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "HexEditor.h"

void createFile() {
	int x = 1816466293;
	std::ofstream file("myData.dat", std::ios::binary);
	file.write( (const char*)&x, sizeof(x));
}

int main() {
	createFile();
	
	HexEditor hexEdit("myData.dat");
	hexEdit.viewFile();
	hexEdit.change(1, "68"); // 68x0 h  (value in hex)
	hexEdit.change(2, 68);   // 68   D  (value in decimal)
	hexEdit.viewFile();
	hexEdit.remove();
	hexEdit.viewFile();
	hexEdit.save();

	HexEditor hexEditCopy("myData.dat");

	hexEdit.add(46);         // 46   .  (value in decimal)
	hexEdit.add("15");       // 15x0    (value in hex)
	hexEdit.change(0, "4B"); // 4Bx0 K  (value in hex)

	hexEditCopy.viewFile();
	hexEdit.viewFile();
}