New course! Every coder should learn Generative AI!
Try a free lesson+ 3
Well, as everyone is saying, technically i think it's impossible, but I have an idea:
You can create a dictionary. If you think about it, the way dictionaries work make them suitable for storing "variables". Just set the key as the user input and the value as the value of the "variable" with that name. When you want to access the value, just search in the dictionary indexing the key: the "name" of the value.
I made an example with Python for you to see:
https://code.sololearn.com/clIBtHe32S3S/?ref=app
+ 7
I think it is impossible Because the process of creating each variable is done at compile time
what is the benefit of this tricky ?
+ 4
Yes, php has this ability. They are called "variable variables".
+ 2
I don't know of any way that is possible in C++. If there is, it would probably be some hacky work around way that wouldn't be easy.
+ 2
I think it's impossible . We can store a value to a variable by taking input from the user but we cannot take variable name as a input , we can only take values.