Hello, i have done this program in about 5 minutes. I was trying to modify a .dat file to actually (Basic hack) a small game called Cave story.
Here's the code if anyone is curious about .dat files.
Code:#include <iostream> #include <fstream> using namespace std; struct CaveStoryDat { int str[50]; }; int main() { CaveStoryDat dat; int choice = 0; int value = 0; int number = 0; int foundvalues[50]; ifstream filer; ofstream filew; filer.open("Profile.dat", ios::binary); filer.read((char*)&dat, sizeof(CaveStoryDat)); filer.close(); while(1) { system("cls"); for(int i = 0; i < 50; i++) { cout << i <<"| "<<dat.str[i]<<" | "<<endl; } cout <<"\n\n\n"; cout <<"1.Search values."<<endl; cout <<"2.Modify values."<<endl; cout <<"3.Save File."<<endl; cout <<"4.Reload file."<<endl; cin >> choice; cin.get(); switch(choice) { case 1: system("cls"); cout <<"Exact value?: "<<endl; cin >> value; cin.get(); system("cls"); for(int i = 0; i < 50; i++) { if(dat.str[i] == value) { foundvalues[i] = dat.str[i]; } } for(int i = 0; i < 50; i++) { if(foundvalues[i] == value) { cout << i <<"| "<<foundvalues[i]<<" | "<<endl; } } choice = 0; cin.get(); break; case 2: cout <<"Number?: "; cin >> number; cin.get(); system("cls"); cout <<"Value: "<<dat.str[number]<<endl; cout <<"Modify it's value to?: "<<endl; cin >> value; cin.get(); dat.str[number] = value; break; case 3: filew.open("Profile.dat", ios::binary); filew.write((char*)&dat, sizeof(CaveStoryDat)); filew.close(); case 4: filer.open("Profile.dat", ios::binary); filer.read((char*)&dat, sizeof(CaveStoryDat)); filer.close(); } } return 0; }



LinkBack URL
About LinkBacks
.



