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);
} 5 1663 ar*****@gmail.com wrote: 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); }
And what is your problem? What are you expecting said code to do, and
what is said code actually doing?
Maybe there are someting problem about your display function?
plz show your class implementations and the errors or warnings supplied
by the compiler
The program compiles perfectly.the display fuction is a normal class
funtion,which displays the members
Arun,Please provide the compiler error messages.
And the operating system you are working with .
<ar*****@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com... 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); }
This is not a complete compilable program. For one we can't see what
product.getdata() does, nor product.display()
Please show us the smallest compilable program that demonstrates the
problem. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: George Marshall |
last post by:
Hi all, my question is what should I do with a pointer
to be used inside a function ?
The following function should take a pointer to a null
terminated array of chars, do something with it, and...
|
by: Boris Condarco |
last post by:
Hi gurus,
I'm using excel 2000 to show data that comes from datagrid. The problem is
that for any reason the asp.net application maintains the excel open, even
though, i do close it. Besides,...
|
by: Amjad |
last post by:
Hi,
I want to make a project that calls and executes a function (VB code) made
in a seperate file in the Application Folder. I know I can create the
function in my project and call it internally,...
|
by: Simon |
last post by:
Hi,
I have written an ActiveX object to resize images and upload them to a
database, this all works fine but when I close internet explorer the
process iexporer.exe is still running in my task...
|
by: MikeT |
last post by:
This may sound very elementary, but can you trap when your object is
set to null within the object?
I have created a class that registers an event from an object passed
in the constructor. When...
|
by: Smokey Grindle |
last post by:
I have a list box on my form, but I need to databind it to a data table that
is a private member of the form's class... so I basically have
Public Class MyForm
priate m_MyTable as new datatable...
|
by: Marty James |
last post by:
Howdy,
I was reflecting recently on malloc.
Obviously, for tiny allocations like 20 bytes to strcpy a filename or
something, there's no point putting in a check on the return value of
malloc....
|
by: tdahsu |
last post by:
All,
I'd appreciate any help. I've got a list of files in a directory, and
I'd like to iterate through that list and process each one. Rather
than do that serially, I was thinking I should...
|
by: Carlo Milanesi |
last post by:
Hello,
traditionally, in C++, dynamically allocated memory has been
managed explicitly by calling "delete" in the application code.
Now, in addition to the standard library strings, containers,...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |