#include #include #include #include #include #include #include #include //-----------------------------------------------------------------\par \par \par class inventory\par \{\par \tab char name[25];\par \tab int code,copy;\par \tab float cost;\par \tab char stock[3];\par \tab char datestr[9];\par \tab char timestr[9];\par \par \tab public:\par \tab\tab void rdata(void);\par \tab\tab void wdata(void);\par \tab\tab void menu(void);\par \tab\tab void display(void);\par \tab\tab void mainpage(void);\par \tab\tab void check(void);\par \tab\tab void purchase(void);\par \tab\tab void tranrdata(void);\par \tab\tab void tranwdata(void);\par \tab\tab void displaytran(void);\par \tab\tab void date(void);\par \};\par //-----------------------------------------------------------------\par \par \par void inventory::rdata(void)\par \{\par \tab cout<<"\\n\\n\\t ENTER THE DETAILS OF THE BOOK :";\par \par \tab cout<<"\\n\\n\\t ENTER THE BOOK NAME ::";cin>>name;\par \par \tab cout<<"\\n\\n\\t ENTER THE CODE OF THAT BOOK ::";cin>>code;\par \par \tab cout<<"\\n\\n\\t ENTER THE COST OF THE BOOK ::";cin>>cost;\par \par \tab cout<<"\\n\\n\\t ENTER THE STOCK OF THE BOOK ::";cin>>stock;\par \tab\par \tab cout<<"\\n\\n\\t ENTER THE NO. OF COPIES ::";cin>>copy;\par \par \par \}\par //------------------------------------------------------------------\par void inventory::tranrdata(void)\par \{\par \tab cout<<"\\n\\n\\t ENTER THE DETAILS OF THE BOOK ::";\par \par \tab cout<<"\\n\\n\\t ENTER THE BOOK NAME ::";cin>>name;\par \par \tab cout<<"\\n\\n\\t ENTER THE COST OF THE BOOK ::";cin>>cost;\par \par \tab cout<<"\\n\\n\\t ENTER THE NO. OF COPIES ::";cin>>copy;\par \}\par //------------------------------------------------------------------\par void inventory::date (void)\par \{\par \par \par \tab _strdate(datestr);\par \tab cout<<"\\n\\n\\t Date ::\\t"<>name1;\par \tab cout<<"\\n\\n\\n\\t\\t\\tEnter the password here\\t:";\par \tab cin>>password;\par \}\par //-----------------------------------------------------------------------\par \par void inventory::check(void)\par \par \{\par \par \par \par \par \tab int x;\par \tab x=strcmp("yes",stock);\par \tab if(x!=0)\par \tab\tab cout<<"\\n\\n\\t The required book is not available";\par \tab else\par \tab\tab cout<<"\\n\\n\\t The required book is available";\par \par \par \}\par //------------------------------------------------------------------------\par void inventory::purchase(void)\par \{\par \par \tab int no;\par \tab cout<<"\\n\\n\\tENTER THE NO OF COPIES YOU WANT\\t::";cin>>no;\par \tab copy=copy-no;\par \tab char st[3]="no";\par \tab if (copy==0)\par \tab\tab strcpy(stock,st);\par \}\par //------------------------------------------------------------------------\par \par \par int main()\par \{\par \par \tab inventory item;\par \tab fstream item;\par \tab fstream file1;\par \tab int choice;\par \tab char ans;\par \tab char ch;\par \tab item.mainpage();\par \tab system("cls");\par \par \par \tab while(1)\par \par \par \tab\{\par \tab\tab file.open("stock1.dat",ios::ate|ios::in|ios::out|ios::binary);\par \par \par \tab\tab item.menu();\par \tab\tab system("colour df");//purple\par \tab\tab cout<<"\\n\\n\\t ENTER YOUR CHOICE (1-7)::";\par \tab\tab cin>>choice;\par \tab\tab switch(choice)\par \tab\tab\{\par \par case1:\par \par \tab\tab\{\par \par \tab\tab\tab do\par \par \tab\tab\tab\{\par \tab\tab\tab\tab item.rdata();\par \tab\tab\tab\tab file.write((char*) & item,sizeof(item));\par \tab\tab\tab\tab cout<<"\\n\\n\\t WANT TO ADD ANY MORE RECORDS(Y/N)::";\par \tab\tab\tab\tab cin>>ans;\par \tab\tab\tab\}while(ans=='Y'|| ans=='y');\par \tab\tab\tab //find number of objects in a file\par \tab\tab\tab int last=file1.tellg();\par \tab\tab\tab int n=last/sizeof(item);\par \tab\tab\tab cout<<"TOTAL NO. OF RECORDS::"<>ans;\par \tab\tab\tab\tab if (ans=='y')\par \tab\tab\tab\tab\{\par \tab\tab\tab\tab\tab cout<<"\\nENTER THE OBJECT NUMBER HERE";\par \tab\tab\tab\tab\tab int object;\par \tab\tab\tab\tab\tab cin>>object;\par \tab\tab\tab\tab\tab cin.get(ch);\par \tab\tab\tab\tab\tab int location=(object-1)*sizeo(item);\par \tab\tab\tab\tab\tab if(file.eof())file.clear();\par \tab\tab\tab\tab\tab file.seekp(location);\par \tab\tab\tab\tab\tab file.read((char *) & item,sizeof(item));\par \tab\tab\tab\tab\tab item.check();\par \tab\tab\tab\tab\tab item.display();\par \tab\tab\tab\tab\tab item.wdata();\par \tab\tab\tab\tab\tab item.purchase();\par \tab\tab\tab\tab\tab cout<<"\\n\\n----------------------------------------------------------";\par \tab\tab\tab\tab\tab file.seekp(location);\par \tab\tab\tab\tab\tab file.write((char *) & item,sizeof(item));\par \tab\tab\tab file1.write((char *) & item,sizeof(item));\par \tab\tab\tab\tab\tab cout<<"\\n Press any key to see menu...\\n"<>ans;\par \tab\tab\tab\tab\}while(ans=='Y'|| ans=='y');\par \tab\tab\tab\tab int last=file.tellg();\par \tab\tab\tab\tab int n=last/sizeof(item);\par \tab\tab\tab\tab cout<<"TOTAL NO. OF TRANSACTIONS::"<>ans;\par \tab\tab\tab if(ans=='y'||ans=='Y')\par \tab\tab\tab\{\par \par \par \tab\tab\tab\tab return 0;\par \tab\tab\tab\}break;\par \par \par \tab\tab default:cout<<"\\n\\t\\tError input,try again";\par \tab\tab\tab\}\par \par \tab\tab\tab file close();\par \tab\tab\tab\}\par \tab\tab\tab\}\par }
Wow that's cool, i'll take it, are u sure there is no error?.. Don't forget to use code tag..
That's cool.. Are u sure there is no error.. Cause i can't fix it.. Dont forget to use code tag.. Thanks..
Is there a question in there someplace?
I think the question is: "are you able to read this?!?".
I'm sorry, I'm not :( ...