1
I have commands in a string something like:
string comm = "int x; cout << \"Digite um número\"; cin << x;";
My idea is to execute the commands that are in this string, having the result as if I had typed:
int x
cout << "Digite um número";
cin << x;
Is there a command that does this?
I thought of using reader that identifies patterns and performs functions, but this would be very complicated, beyond what, do not know how to create variables.
I thought to write a file . cpp with the contents of the string and have the compiler run, this is possible?
– Felipe Nascimento
Of course, of course, in practice this has no use in this simple way, and it has enormous disadvantages, so it gets kind of in the theoretical field.
– Maniero
And what would work? As I said in the question, the biggest problem is declaring variables.
– Felipe Nascimento
No, that’s not the biggest problem, what you’re wondering is a comma in a whole book, give up this idea.
– Maniero