I am trying to create an inventory-esque program. I want to be able to enter in some data about a product and then save it into another struct and then enter another if so desired. The problem is i enter in one item and all of it's properties and then when it loops around to enter another one, it skips the forst entry. I think it has to do with my string instruction.
Here is the code:
Output Problem after first item & description was entered.Code:#include <iostream> #include <string> #include <fstream> #include <cstdlib> #include <conio.h> #include <iomanip> using namespace std; struct co { string name; //Product Name string model; //Model Number string descrip; //Description double Rprice; //Retail price double priceP; //Price Paid }; int main() { //After data is entered, save it into another struct to be searched later. //Create counter int proceed=1; string decision; co inven; //Declare struct for inventory while(proceed) { cout<<"Enter the Product name: "; //Product Name getline ( cin, inven.name ); cout<<"Enter the Model number: "; //Model Number getline(cin,inven.model); cout<<"Enter Description of Item: "; //Description getline(cin,inven.descrip); cout<<"Retail Price Paid: "; //Retail Price cin>>inven.Rprice; cout<<"Actual Price Paid: "; //Price Paid cin>>inven.priceP; cout<<"Would you like to add another item? (Yes/No) "; cin >> decision; if (decision!="yes") proceed=0; else proceed=1; } //Display cout <<"\n-----------------------------------------------\n" << endl; cout << "Product Name: " << inven.name << endl; cout << "Model Number: " << inven.model << endl; cout << "Product Description: " << inven.descrip << endl; cout << "Retail Price: $" << inven.Rprice << endl; cout << "Actual Price: $" << inven.priceP << endl; return 0; }
Any help would be much appreciated.Code:Enter the Product name: Enter the Model number:
Gracias.



LinkBack URL
About LinkBacks



