I am trying to set up a storefront simulation in the console for a school project. The user goes through some prompts and then has the opportunity to "buy supplies", which is what this module will do when it's done.
Right now, I am getting error messages about datatypes. Visual Studio is advising that I need my variable to be a boolean, which I don't know how to interpret in this context. I think it is easy for a person to see what I am trying to do.
Can you please advise me on how I can fix this ?
The outputs for each option are placeholders; I intend the user to be funneled through more menus specific to each of the 5 choices.
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <limits>
int main()
{
int nNumCup = 0, nNumLem = 0, nNumSug = 0, nNumIce = 0;
std::string sStoreInput01, A, B, C, D;
std::cout << "You currently have \n"
<< nNumCup << " cups, " << nNumLem << " lemons, " << nNumSug << " cups of sugar and " << nNumIce << " icecubes. \n"
"If you want to purchase more supplies, you can choose from \n"
"\n"
"A) cups \n"
"B) lemons \n"
"C) cups of sugar \n"
"D) icecubes \n"
"\n"
"Please make your selection. Otherwise, type 0 to finish shopping. \n";
getline(std::cin, sStoreInput01);
//Everything above this note is fine; below code is problematic:
if (sStoreInput01 = 0) {
std::cout << "return (this feature isn't set up yet)";
}
else if (sStoreInput01 = A) {
std::cout << "Go to Cups";
}
else if (sStoreInput01 = B) {
std::cout << "Go to Lemons";
}
else if (sStoreInput01 = C) {
std::cout << "Go to Sugar";
}
else if (sStoreInput01 = D) {
std::cout << "Go to Ice";
}
else
std::cout << "error";
return 0;
}
I didn't define "0" as a string because that caused errors and putting it in quotes didn't help.
Errors below, sans one which isn't shown but it's another thing about booleans.

sStoreInput01 = 0were you tryting to comparesStoreInput01 == "0"?sStoreInput01 == 0? This won't compile because you can't compare astringto anint,sStoreInput01 == "0"should work.