Habsburg

Prog2Vj6Test

Nov 26th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. bool status() {
  2.     fstream ind, dat;
  3.     dat.open("datoteka.dat", fstream::binary | fstream::in);
  4.    
  5.     if(!dat) {
  6.         cout << "status 0 = nema datoteke!";
  7.         cout << "Kreiram datoteku.... Datoteka kreirana!\n";
  8.         dat.open("datoteka.dat", fstream::binary | fstream::out);
  9.         ind.open("datoteka.ind", fstream::binary | fstream::out);
  10.         dat.close();
  11.         dat.clear();
  12.         ind.close();
  13.         ind.clear();
  14.         return false;
  15.     }
  16.  
  17.     if( dat.peek() == fstream::traits_type::eof()) {
  18.         cout << "status 1 = datoteka je prazna!\n";
  19.     } else {
  20.         streampos fsize = 0;
  21.         dat.seekg(0, fstream::end);
  22.         fsize = dat.tellg() - fsize;
  23.         cout << "status 2 = datoteka sadrzi " << fsize/sizeof(Abcd)<< " zapisa\n";
  24.     }
  25.    
  26.     dat.close();
  27.     dat.clear();
  28.     ind.close();
  29.     ind.clear();
  30.     return true;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment