You are here:

C++/c++ and files


i am a +2 student.need a c++ project.aprogramme including class and data files.pls take concern.thanks very much

Hi dear jisha !

Your question is not too specific , you are looking for a project but you didn't specify the objective of your project !

Before using files in your c++ programs you should have some basic knowledge about the files , different types of file opening modes etc ,
Here im presenting a simple C++ program that uses files and classes hope you will get some ideas over file

class record
     char name[25];
     int age;
     friend class sample;

class sample
     fstream iofile;

  public :
     void readinput();
     void disp();

sample :: sample()
{   // open file in I/O mode"default.txt" , ios::in | ios::out);
     cerr<<"Error opening file :";
void sample :: disp()
  // Place the get pointer at the beginning of file
  while(*)&rec , sizeof(rec)))
     cout<<"Empl Name : " <<;
     cout<<endl<<"Emp age :"<<rec.age<<endl;

void sample :: readinput()
  char opt = 1;

     cout<<"Enter employee name :";
     cout<<"Enter age :";
     // write data's
     iofile.write((char*) &rec , sizeof(rec));
     cout<<" Wish to add another rec <y/n>?:";
  }while( opt != 'n');

void main()
  sample a;


Feel free to ask follow up if you have any detailed discussions over files !
Thanks and Regards
Prince M. Premnath


All Answers

Answers by Expert:

Ask Experts


Prince M. Premnath


Years of research in C/C++ Will bring you all facts regarding , OOPS , SVGA , MOUSE , BIOS , IVT , Feel free to query me :-)


More than 5 years


©2017 All rights reserved.