background image

//==============================================================
// Obsluga plikow - In / Out
//     I/O strumienie C++, pliki tekstowe.
//
// ver data       temat                                    autor
// 100 2005/10/12 Pierwszy projekt                 J. Malinowski
// 101 2007/11/08 Cleanup                                    JM
// 102 2009/11/10 Cleanup                                    JM
//==============================================================

#include <iostream>
#include <fstream>

using namespace std;

//==============================================================

int main()
{
   float x=

5.0

, y;

   char name[

30

];

   cout << 

"File name: "

;

   cin.getline(name, 

30

);

//   cin>>name;
//----------------------------
//Zapis

   ofstream JMzapis(name);

   JMzapis << x << endl;

   JMzapis.close();

//----------------------------
//Odczyt

   ifstream JModczyt(name);

   while

1

 ) {

       JModczyt >> y;
       if( JModczyt.eof() )
          break;
       cout << y << endl;
   }

   JModczyt.close();

//----------------------------
//    system("PAUSE");

    return 

0

;

}

//==============================================================
/*
   while( !JModczyt.eof() ) {
       JModczyt >> y;
       cout << y << endl;

background image

   }
*/