Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <limits>
- using namespace std;
- int main()
- {
- long bytelength, x;
- char * buffer, filepath[256], newfilepath[256];
- cout << "Please type the location of your file:\n";
- cin.getline(filepath,256);
- cout << "\nNow, type the name you wish to save the file as later: \n";
- cin.getline(newfilepath,256);
- ifstream file (filepath, ios::in | ios::binary);
- ofstream newfile (newfilepath, ios::out | ios::binary);
- file.seekg(0,ios::end);
- bytelength = file.tellg();
- file.seekg(0,ios::beg);
- buffer = new char [bytelength];
- file.read(buffer, bytelength);
- for(x = 0; x < bytelength; x++)
- {
- buffer[x] = buffer[x] ^ 0xFF;
- }
- newfile.write(buffer,bytelength);
- file.close();
- newfile.close();
- delete[] buffer;
- cout << "New file complete. Press enter to exit.\n";
- std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' ); //Thanks, Duoas. xD..
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment