Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <iostream.

h>
class person
{
public:
char name[80];
int age;
public:
void getData(){
cout << "Enter name: "; cin >> name;
cout << "Enter age: "; cin >> age;
}
};
int main(){
person pers;
pers.getData();
ofstream myfile;
myfile.open ("example.txt");
myfile << "Name :- "<<pers.name<<"\n"<<pers.age;
myfile.close();
return 0;
}

You might also like