Start New Discussion within our Software Development Community

hi every body try out this code it can store your info and then retriaeve it ant any time you wish.
They are two codes each wrote separatly so first write the outputting code and run it.
Then write the inputting code and also run it
have fun:lol:

//code for out putting on the file private.dat.

#include<iostream.h>

#include<fstream.h>

#include<stdlib.h>

void main()

{

ofstream  my_record("private.dat",ios::out);

if(!my_record)

{

cerr<<"the fail can not be created"<<endl;

exit(1);

}

int age;

char name[10];

int registration;

while(cin>>age>>name>>registration)

{

my_record<<age<<'    '<<name<<'    '<<registration<<endl;

cout<<"---"<<endl;

}







//code for in putting on the file private.dat.

#include<iostream.h>

#include<fstream.h>

#include<stdlib.h>

void display(int,const char*const,int);

void main()

{

ifstream  my_record("private.dat",ios::in);

if(!my_record)

{

cerr<<"the fail can not be found"<<endl;

exit(1);

}

int age;

char name[10];

int registration;

cout<<"AGE\t NAME \tREGESTRATION"<<endl;

while(my_recod>>age>>name>>registration)

diplay(age,name,registration);

}

void display(int d,const char*const t, int y)

{

cout<<d<<'\t'<<'\t'<<t<<'\t'<<'t'<<y<<endl;

}