A
arunvnk
int main()
{
product g;
product t;
fstream k;
k.open("stock.txt",ios::app|ios::in);
int op=0;
static int count=0;
//k.open("stock.txt",ios::app,ios::in);
while(op<4)
{
clrscr();
cout<<"\n1.Enter details";
cout<<"\n2.Modify";
cout<<"\n3.Display";
cin>>op;
if(op==1)
{
g.getdata();
k.write((char*)&g,sizeof(g));
count++;
}
if(op==2)
{
int code;
cout<<"\nEnter code of product";
cin>>code;
k.seekg(0,ios::cur);
for(int i=0;i<count;i++)
{
k.read((char*)&t,sizeof(t));
if(t.retc()== code);
{
t.getdata();
k.seekp(-sizeof(t),ios::cur);
k.write((char*)&t,sizeof(t));
}
}
}
if(op==3)
{
product h;
k.seekg(0,ios::cur);
for(int i=0;i<count;i++)
{
k.read((char*)&h,sizeof(h));
h.display();
}
}
}//while
k.close();
return(0);
}
{
product g;
product t;
fstream k;
k.open("stock.txt",ios::app|ios::in);
int op=0;
static int count=0;
//k.open("stock.txt",ios::app,ios::in);
while(op<4)
{
clrscr();
cout<<"\n1.Enter details";
cout<<"\n2.Modify";
cout<<"\n3.Display";
cin>>op;
if(op==1)
{
g.getdata();
k.write((char*)&g,sizeof(g));
count++;
}
if(op==2)
{
int code;
cout<<"\nEnter code of product";
cin>>code;
k.seekg(0,ios::cur);
for(int i=0;i<count;i++)
{
k.read((char*)&t,sizeof(t));
if(t.retc()== code);
{
t.getdata();
k.seekp(-sizeof(t),ios::cur);
k.write((char*)&t,sizeof(t));
}
}
}
if(op==3)
{
product h;
k.seekg(0,ios::cur);
for(int i=0;i<count;i++)
{
k.read((char*)&h,sizeof(h));
h.display();
}
}
}//while
k.close();
return(0);
}