Search This Blog

Sunday, 23 August 2020

File handling 1

 #include<iostream>

#include<fstream>

using namespace std;


const char *FILE_NAME ="c://txt_file.txt";

int main()

{

ofstream fout(FILE_NAME);

cout<<"Enter some text::";

char str[100];

cin>>str;                  //write the text to file;;

fout<<str<<endl;

                            //close file

ifstream fin(FILE_NAME);

char ch;

cout<<"Data read from the file:\n ";

while(fin.get(ch)) 

cout<<ch;

fin.close();

                           


return 0;

}


No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts