Friday 30 April 2021

File Handling in C++ Qus - 2

 #include<fstream.h>

#include<iostream.h>

#include<conio.h>

int main()

{

clrscr();

ofstream fout;

fout.open("29AP1.txt",ios::noreplace);

cout<<"Enter Your ID"<<endl;

int id;

cin>>id;

fout<<id<<endl;

cout<<"File Created"<<endl;

fout.close();

ifstream fin;

fin.open("29AP1.txt",ios::in);

char ch;

cout<<"Content of File"<<endl;

while(!fin.eof())

{

fin.get(ch);

cout<<ch;

}

fin.close();

getch();

}

No comments:

Post a Comment