C++ programs
C++ program to implement streams and files in text and binary modes with object storage.
Write a C++ program to implement streams and files in text and binary modes with object storage.
PROGRAM:
•	TEXT MODE
#include<iostream .h="">
#include<conio .h="">
#include<fstream .h="">
#include<string .h="">
void main()
{
	int j;
	char ch;  //character to read
	char str[]="Sies college of management studies";
	clrscr();
	ofstream outfile;
	outfile.open("test.txt"); //create file for output
	for(j=0;j<strlen binary="" ch="" character="" college="" cout="" create="" display="" each="" endl="" eof="" error="" file="" for="" getch="" ifstream="" include="" infile.get="" infile.open="" infile="" input="" iostream.h="" it="" j="" management="" mode="" n="" nfile="" of="" or="" outfile.close="" outfile.put="" output="" read="" str="" studies="" test.txt="" text.txt="" to="" until="" while="" write="" written="" www.adkool.com="" xyz="">
#include<conio .h="">
#include<fstream .h="">
#include<iostream .h="">
class person
{
protected:
	char name[80];
	int age;
public:
	void get_data()     //get person's data from user
	{
		cout<<"\nEnter name : ";
		cin>>name;
		cout<<"\nEnter age : ";
		cin>>age;
	}
	void show_data()         //display person's data
	{
		cout<<"\nNAME : "<<name :="" age="" ch="" char="" cin="" clrscr="" cout="" create="" data="" details="" do="" enter="" file.open="" file.write="" file="" from="" fstream="" input="" ios::app="" ios::binary="" ios::in="" ios::out="" main="" more="" n="" nage="" nenter="" nwant="" output="" p1.get_data="" p1="" person="" s="" sample.txt="" sizeof="" to="" user="" void="" write="" y="">>ch;
	}while(ch=='y');
	file.seekg(0);     //reset to start of file
	file.read((char *)&p1,sizeof(p1));  //read first person data
	while(!file.eof())
	{
		cout<<"\n";
		p1.show_data();
		file.read((char *)&p1,sizeof(p1));
	}
	cout<</name></iostream></fstream></conio></strlen></string></fstream></conio></iostream>