Advertisement
neogz

FIL - otvaranje i pisanje file

Aug 28th, 2014
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. /*
  2.     maniplulisanje file-ovima
  3. */
  4.  
  5. #include <iostream>
  6. #include <fstream> 
  7. using namespace std;
  8.  
  9. char crt[] = "\n-------------------------------------------------\n";
  10.  
  11. int main(){
  12.  
  13.     ofstream upis("mojFajl.txt");
  14.     if (upis.fail())        cout << "UPIS :: Greska: Nemoguce otvoriti fajl....\n";
  15.     else{
  16.         upis << crt << "Univerzitet \"Dzemal Bijedic\"" << endl;
  17.         upis << "Fakultet informacijskih tehnologija" << endl;
  18.         upis << "Sjeverni logor 12, Mostar" << endl;
  19.         upis << "Tel/Fax: +387 (0) 36 281 166" << crt;
  20.     }
  21.     upis.close();
  22.  
  23.     //**********************************************************
  24.  
  25.     ifstream ispis("mojFajl.txt");
  26.     if (ispis.fail())
  27.         cout << "ISPIS :: Greska: Nemoguce otvoriti fajl....\n";
  28.     else{
  29.         cout << crt<<"Ispisujem sadrzaj file-a: " << crt;
  30.         char znak;
  31.         while (ispis.get(znak))
  32.             cout << znak;
  33.     }
  34.     ispis.close();
  35.  
  36.     system("pause>null");
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement