Is it possible to declare a variable in C, the name of which is given by the user at runtime? If yes, then how?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, this is not possible: variable names do not survive the compilation step, becoming addresses and offsets “baked into” the compiled binary code.
It is, however, possible to declare a variable the name of which is given by the developer at compile-time by using a
-Dor a comparable option of your C compiler.