File Handling input from user.

 

#include<iostream>

#include<fstream>

#include<string>

using namespace std;

int main() {

       string s;

       fstream file132;

       file132.open("Kumar.txt", ios::out);

       if (!file132)

       {

              cout << "file does not open";

       }

       else

       {

              cout << "file open successfully " << endl;

              getline(cin, s);

              file132 << s;

              file132.close();

              file132.read("Kumar.txt", ios::out);

              cout<<"Output of the program:  " <<endl<< s;

       }

       cout << endl;

       system("pause");

}



Comments

Popular Posts