Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- int main ( )
- {
- ifstream file ( "test.txt" );
- string line;
- try
- {
- if ( file.fail ( ) )
- {
- throw (string) "unable to open the file\n";
- }
- while ( getline ( file , line ) )
- {
- cout << line << '\n';
- }
- file.close ( );
- }
- catch ( string error )
- {
- cout << error << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement