Is there anyway you can store data in a c++ console application, transfer it to a different variable, then reuse the variable?
Why I want this: I want to have the user input order details for an order then for the program to be able to store them so the program can recreate another order.
Current Code:
int quant;
int cost;
int selling;
int profit;
NewOrder:
cout <<""<< endl;
cout << "Enter an Order Number: " << flush;
getline(cin, ord);
cout << "Enter a Product ID: " << flush;
getline(cin, Prod);
cout << "Enter a Quantity: " << flush;
cin>>quant;
Pricing:
cout << "Enter a cost per unit: " <<char(156) << flush;
cin >> cost;
cout << "Enter a selling price per unit: " <<char(156) << flush;
cin >> selling;
Sleep(2000);
cout << endl;
cout << "Your order Details are:" << endl;
cout << "Order Number: " << ord << endl;
cout << "Product: " <<Prod << endl;
cout << "Quantity:" << quant << endl;
cout << "Total Cost: " <<char(156) << (quant*cost) << endl;
cout << "Total Selling Price: " <<char(156)<< (quant*selling) << endl;
profit = ((quant*selling) - (quant*cost)); //Assigning a value to profit.
cout << "Total Profit: " <<char(156)<< profit << endl;
if (profit < 0) {
cout << "You have a negative profit. Please change your pricing." << endl;
Sleep(3000);
goto Pricing; }
Currently, it lets the user input the details to one order and then displays them. I want to have it so the program can enter more then one order and going by order number can recall them. Can I use the programs memory to do this or will need set it to a SQL DB?
If so, how do I setup the SQL connection?
If I can do it within the memory, how? I have been looking around and I cant create and declare variables during runtime.