'Expanding a variable'

Could someone please explain to me how to use the value of a variable instead of the variable itself. For example, if I wanted to prompt the user for the name of a variable using scanf("%s", &varname) and then int [value of varname]. SO if the user entered blue, there would be a new variable called blue.

I presume you’re thinking about C++ here because this is a Haiku forum and the syntax in your examples resembles that language.

You cannot do what you’re describing. C++ variables must be declared at compile time. It is likely judging again from the example that you’re just thinking about your problem in the wrong way.

If you in fact have some reason to associate arbitrary input strings with values then the right structure is probably an associative array. C++ does not natively include an associative array type, but you can roughly simulate one using hash tables. Judging from the state of your knowledge I’d suggest that you find something easier to try first.

In some programming languages what you’re trying to do is possible, but it’s still almost certainly the Wrong Thing™, so in a way you’re lucky that you aren’t using one of those languages.