-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileio.cpp
More file actions
37 lines (33 loc) · 922 Bytes
/
fileio.cpp
File metadata and controls
37 lines (33 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream fout;
fout.open("test.txt", ios::out);
fout << "Hello World again";
fout.close();
cout << "File created successfully";
return 0;
}
#include <iostream>
#include <fstream>
using namespace std;
#include <exception>
/********************************************************************
int main() {
try {
ofstream fout("test.txt", ios::out);
fout << "Hello World again";
fout.close();
cout << "File created successfully";
}
catch (const ios_base::failure& e) {
cerr << "File operation failed with exception : " << e.what() << endl;
}
catch (const exception& e) {
cerr << "An exception occurred: " << e.what() << endl;
}
return 0;
}
*********************************************************************/