Note that there are some explanatory texts on larger screens.

plurals
  1. POoverwriting the .txt file after user edit it C++
    text
    copied!<p>i want to let user edit the txt file and ItemID is a unique character, i wanted to do checking if user key in a similar ItemID existed in the system, an error will appear.</p> <p>but after i do testing by keying in an Item ID that already exists, it successfully prompt "ItemID already exists in stock database" but when i tried to key in another ItemID not existing in the system, nothing happens, it won't show "returning to main menu" or exit to the main menu. </p> <p>please advise</p> <pre><code> switch (choice) { case 1: while (true) { if (duplicate == true) { system("clear"); cout &lt;&lt; "\E[1;32m" &lt;&lt;itemID &lt;&lt; "\E[0m already exists in the stock database!" &lt;&lt; endl; cout &lt;&lt; "Please enter a unique Item ID that is not used yet" &lt;&lt; endl; cout &lt;&lt; "\E[1;32mItem ID:\E[0m\t" &lt;&lt; stockVectorTemp[vectorChoice - 1].getItemID() &lt;&lt; endl; cout &lt;&lt; "\E[1;32mDescription:\E[0m\t" &lt;&lt; stockVectorTemp[vectorChoice - 1].getItemDesc() &lt;&lt; endl; cout &lt;&lt; "\E[1;32mTotal Quantity:\E[0m\t" &lt;&lt; stockVectorTemp[vectorChoice - 1].getTotalQty() &lt;&lt; endl &lt;&lt; endl; } duplicate = false; cout &lt;&lt; logo_EditStock &lt;&lt; endl; cout &lt;&lt; "Please enter new ItemID: "; getline(cin, input); for (int i = 0; i &lt; stockVector.size(); i++) { if (stockVector[i].getItemID() == itemID) stockVector[i].setItemID(input); duplicate = true; writeStockDatabase(); // cout &lt;&lt; "Returning to main menu..." &lt;&lt; endl &lt;&lt; endl; } if (!duplicate) break; } cout &lt;&lt; "Returning to main menu..." &lt;&lt; endl &lt;&lt; endl; </code></pre> <p>break;</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload