Raerie 0 Newbie Poster

hi
this part of my code is suppose to read from a file and update the info in the quantity of the user's choice and write back all the info in the same order to the file but with the update quantity. I am able to update to information but the curent info is not updating in the file.
any assistance will be greatly appreciated

inFile.open("deskTop.txt");
            outFile.open("deskTop.txt");
            outfile.open("cashierFile.txt",ios::in|ios::app);
            num = 0;


             while(!inFile.eof())
                    {
                        index++;
                        inFile >> DESKTOPS[index].cateGory.brandName >> DESKTOPS[index].cateGory.type
                           >> DESKTOPS[index].cateGory.costPrice >> DESKTOPS[index].cateGory.salePrice
                           >>  DESKTOPS[index].cateGory.qty >> DESKTOPS[index].screenS ;




                        cout << index <<"\t"<<DESKTOPS[index].cateGory.brandName ;
                        cout << "\t"<<  DESKTOPS[index].cateGory.type ;
                        cout << "\t"<<  DESKTOPS[index].cateGory.costPrice;
                        cout << "\t"<<  DESKTOPS[index].cateGory.salePrice;
                        cout << "\t"<<  DESKTOPS[index].cateGory.qty;
                        cout << "\t"<<  DESKTOPS[index].screenS << endl;



                    }
                cout << "PLEASE CHOOSE A NUMBER OF THE ITEM U WISH TO PROCESS->";
                cin >> num;

            if (index = num)
                {

                    cout<< " PLEASE ENTER THE QUANTITY TO BE PURCHASED->";
                    cin >> qtyPurchased;
                    DESKTOPS[index].cateGory.qty -= qtyPurchased;
                    cout << DESKTOPS[index].cateGory.qty << endl;
                    total = DESKTOPS[index].cateGory.salePrice * qtyPurchased;//calclates the total sale price
                    cout <<"$" << total << endl;
                    cout << "INPUT AMOUNT CUSTOMER PAID ->";
                    cin>> custTotal;
                    change = custTotal - total;
                    cout << "CHANGE->" << change << endl;
                    cout << "PLEASE ENTER DATE MONTH/YEAR(IN NUMBERS EG:02.09)PROCESSED->";
                    cin >> date;

                    outfile <<"DESKTOPS"<< "\t"<< date <<"\t" <<DESKTOPS[index].cateGory.brandName << "\t"<<DESKTOPS[index].cateGory.type <<"\t"<< DESKTOPS[index].cateGory.costPrice
                            <<"\t"<<DESKTOPS[index].cateGory.salePrice <<"\t"<<DESKTOPS[index].cateGory.qty << "\t"<<qtyPurchased <<"\t"<<  endl;
                }

                        outFile<<"\t"<<DESKTOPS[index].cateGory.brandName
                               <<"\t"<<DESKTOPS[index].cateGory.type
                               <<"\t"<<DESKTOPS[index].cateGory.costPrice
                               <<"\t"<<DESKTOPS[index].cateGory.salePrice
                               <<"\t"<<DESKTOPS[index].cateGory.qty
                               <<"\t"<<DESKTOPS[index].screenS << endl;








                inFile.close();
                outFile.close();
                outfile.close();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.