jeudi 4 juin 2020

Call up variables with inputs, does that works in C++?

I am a hobby programmer. I'm asking for help, because I'm wondering if you can call a variable which is equivalent to the input without the code snippet looking like that:

std::string exampleVariable = "Hello";

std::string exampleInput;
std::cin >> exampleInput;

if(exampleInput == "exampleVariable")
     std::cout << exampleVariable;

I want to get my code so far to have that structure:

Input(Example) => Output(variable named Example)

Can I get some help here? I'd appreciate it. Thanks.





Aucun commentaire:

Enregistrer un commentaire