value in the source code?
I have this "test" function that gets an integer input and a char and I want it to create a variable named with the integer input.
E.g.:
void test(int no, char status[]) {
char tryX[] = status;
std::cout << status << std::endl;
}
int main() {
test(1, off);
}
Where "X" (after "try") should be "no" value.
In bash I'd do something like
declare variable${othervariable}=$status
but I don't know how to do it in C++. Any idea?
why is it important for you to name a variable with a parameter ?
Doesn't seem very noobish, but rather strange.
What do you want to achieve by that?
Creating variables at runtime is not possible in C++.
use a std::map<std::string, char[]>, not the perfect solution but it is the only way to achieve that thing in C++ afaik
Обсуждают сегодня