Write a
program to read your name and roll number from keyboard and write it in
“mydata.txt
“ file and read from file in text
mode.
|
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
void
main()
{
int rno,rno1;
char name[10],name1[10];
clrscr();
cout<<"\n Enter your
roll number and name";
cin>>rno>>name;
ofstream
of1("mydata.txt");
of1<<rno<<endl;
of1<<name<<endl;
of1.close();
cout<<"\n Read data
from file\n";
ifstream
if1("mydata.txt");
if1>>rno1;
if1>>name1;
cout<<rno1<<"
"<<name1;
if1.close();
getch();
}
|
File Program 3
Subscribe to:
Posts (Atom)