//Write and Read Text in a FILE
#include<fstream.h>
#include<conio.h>
void main()
{
clrscr();
char name[15];
int age;
ofstream out("text1");
cout<<"\nName:";
cin>>name;
cout<<"\nAge:";
cin>>age;
out<<name<<"\t";
out<<age<<"\n";
out.close();//File is closed
ifstream in("text1");
in>>name;
in>>age;
cout<<"\nName:"<<name<<"\n";
cout<<"Age:"<<age;
in.close();
getch();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.