Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- ifstream file("out.txt", ios::in);
- string name;
- file >> name;
- if (name.empty()) {
- cout << "Enter name: ";
- cin >> name;
- ofstream file2("out.txt", ios::out);
- file2 << name;
- }
- cout << "Hello " << name << "!";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement