Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream> // ifstream, open, eof, close
- using namespace std;
- int main()
- {
- ifstream data_store;
- string line, filename;
- int x = 1;
- cout << "Enter filename\n";
- cin >> filename;
- data_store.open(filename.c_str());
- if (!data_store)
- {
- cout << "File not found" << endl;
- return 0;
- }
- while (!data_store.eof())
- {
- getline(data_store, line);
- cout << x << ": " << line << endl;
- x ++;
- }
- //step 4
- data_store.close();
- return 0;
- }
Add Comment
Please, Sign In to add comment