Hello,
Is it possible to create a string from a variable name?
for example, say i have a variable
type myVariable;
could I get a string as
char* name = "myVariable"
Hope this makes sense
Hello,
Is it possible to create a string from a variable name?
for example, say i have a variable
type myVariable;
could I get a string as
char* name = "myVariable"
Hope this makes sense
yes if it's a custom class and you can just implement a function that returns a string with it's name in it.
Code:string name = myVariable.name
Thanks for the reply.
Is that the only way, what if its not in a class, but if its just a simple primitive type variable?
But then you'd have to manually set the name to whatever you called the variable, so what's the point?
I believe you can use the # pre-processor command to write a macro that will print the variable name you pass to it: http://www.cppreference.com/preprocessor/sharp.html
thanks cpjust, thats exactly what i'm looking for.