I want to be able to change a variable based on user input, but I don't want to use if/else statements. I'm using a lot of variables in my actual code. Is there any way to change a variable from input alone?
#include <iostream>
using namespace std;
int a = 0;
int b = 0;
string input;
int main() {
cin >> input;
*variable specified by input variable* = 1;
}
Aucun commentaire:
Enregistrer un commentaire