Subscribe to Feeds

Send Your COMPLETED Projects To georgepj@hotmail.com

We'll Publish It With Your Name :-)

Programs Can Also Be Downloaded From The Folders Below....[Or Scroll Down]

Count no of records in a File

Click Here To Download C++ File Of This Program

 //Downloaded From www.c4cpp.co.nr  
//(C)2009.All rights reserved.
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdio.h>
#include<fstream.h>
struct stud
{
char name[50];
int rno;
};
void main()
{
clrscr();
stud st;
int i;
ofstream gpj("abcabc.dat",ios::binary|ios::trunc);
if(!gpj)
{cout<<"File Cannot Be Created"<<endl;
}
else
{
int n;
cout<<"How many Students U Want to Enter ???? "<<endl;
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter Name"<<endl;
gets(st.name);
cout<<"Enter Roll No"<<endl;
cin>>st.rno;
gpj.write((char*)&st,sizeof(st));
}gpj.close();
}
int a=0;
ifstream gp("abcabc.dat",ios::binary);
if(!gp)
{
cout<<"File Error"<<endl;
}
else
{
gp.seekg(0);
while(gp.read((char*)&st,sizeof(st)))
{
a++;
}
cout<<"No = "<<a;
gp.close();
}
getch();
}

No comments: