954,479 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Code that stores and retrieves.

0
By Mpiangu on Apr 12th, 2007 1:45 pm

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;

}

exelent:confused:

Mpiangu
Newbie Poster
8 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You