Guest User

Nuclei

a guest
May 1st, 2009
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <limits>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     long bytelength, x;
  10.     char * buffer, filepath[256], newfilepath[256];
  11.    
  12.     cout << "Please type the location of your file:\n";
  13.     cin.getline(filepath,256);
  14.    
  15.     cout << "\nNow, type the name you wish to save the file as later: \n";
  16.     cin.getline(newfilepath,256);
  17.    
  18.     ifstream file (filepath, ios::in | ios::binary);
  19.     ofstream newfile (newfilepath, ios::out | ios::binary);
  20.    
  21.     file.seekg(0,ios::end);
  22.     bytelength = file.tellg();
  23.     file.seekg(0,ios::beg);
  24.    
  25.     buffer = new char [bytelength];
  26.    
  27.     file.read(buffer, bytelength);
  28.    
  29.     for(x = 0; x < bytelength; x++)
  30.     {
  31.           buffer[x] = 0xFF;
  32.     }
  33.    
  34.     newfile.write(buffer,bytelength);
  35.    
  36.     file.close();
  37.     newfile.close();
  38.     delete[] buffer;
  39.    
  40.     cout << "New file complete. Press enter to exit.\n";
  41.     std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' ); //Thanks, Duoas. xD..
  42.     return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment