home *** CD-ROM | disk | FTP | other *** search
- #include <iostream>
- #include <fstream>
-
- using namespace std;
-
- void save1()
- {
- ofstream of;
-
- of.open( "Hello1.dat" );
-
- if (!of.is_open()) {
- cout << "failed to open file" << endl;
- return;
- }
- of << "Hello World!" << endl;
- if (of.fail())
- cout << "failed to write to file" << endl;
- of.close();
- }
-
- void save2()
- {
- ofstream of( "Hello2.dat" );
-
- if (!of) {
- cout << "failed to open file" << endl;
- return;
- }
- of << "Hello World!" << endl;
- if (!of)
- cout << "failed to write to file" << endl;
- }
-
-
-
- int main()
- {
- save1();
- save2();
- return 0;
- }