Advertisement
Guest User

Untitled

a guest
Dec 15th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include<iostream>
  2. #include<istream>
  3. #include<ostream>
  4. #include<fstream>
  5. using namespace std;
  6.  
  7. struct s_pData
  8. {
  9.     int currentL;
  10. };
  11.  
  12. s_pData pData;
  13.  
  14. void loadSettings()
  15. {
  16.  
  17.     // -- First from file -- //
  18.     ifstream file("game.dat", ios::binary);
  19.  
  20.     if (file.good())
  21.     {
  22.         // -- Language -- //
  23.         file.read((char*)&pData, sizeof(pData));
  24.  
  25.         file.close();
  26.     }
  27. }
  28.  
  29. void saveSettings()
  30. {
  31.     ofstream file("game.dat", ios::binary);
  32.  
  33.     if (file.good())
  34.     {
  35.         // -- Language -- //
  36.         file.write((char*)&pData, sizeof(pData));
  37.  
  38.         file.close();
  39.     }
  40. }
  41.  
  42. int main()
  43. {
  44.     loadSettings();
  45.     cout << pData.currentL << endl;
  46.     pData.currentL = 88;
  47.     saveSettings();
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement