Advertisement
lewapkon

czyPlik

Feb 3rd, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. bool FileExists(string fileName) {
  7.     ifstream file(fileName.c_str());
  8.     if (file.is_open()) {
  9.         file.close();
  10.         return true;
  11.     }
  12.     return false;
  13. }
  14.  
  15. int main(int argc, const char * argv[]) {
  16.     string fileName;
  17.     cout << "Podaj nazwe pliku, ktorego istnienie chcesz sprawdzic: ";
  18.     cin >> fileName;
  19.     if (FileExists(fileName))
  20.         cout << "Plik o podanej nazwie istnieje.";
  21.     else
  22.         cout << "Plik o podanej nazwie nie istnieje.";
  23.    
  24.     cout << endl << endl;
  25.     //system("pause");
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement