access computed variable name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ccodehelp
    New Member
    • Jul 2007
    • 4

    access computed variable name

    Hi,

    I have a variable's name stored in a character string:

    char* a = "access_me" ;

    How can I access this variable? Let's say access_me is also of type char* and I want to have functionality of:

    printf("%s", access_me);

    Thanks.
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Originally posted by ccodehelp
    Hi,

    I have a variable's name stored in a character string:

    char* a = "access_me" ;

    How can I access this variable? Let's say access_me is also of type char* and I want to have functionality of:

    printf("%s", access_me);

    Thanks.
    You can write it as
    printf("%s", a); and it will print access_me.

    Regards

    PS Hope I have understood your problem correcty!

    Comment

    • ccodehelp
      New Member
      • Jul 2007
      • 4

      #3
      Originally posted by zodilla58
      You can write it as
      printf("%s", a); and it will print access_me.

      Regards

      PS Hope I have understood your problem correcty!
      I over-simplified my porblem perhaps and of course this is correct. But what I intended actually was:

      I have 'access' stored in char* a. I want to access a variable name constructed from it. like I am appending _func to all these variables, I actually want to access access_func.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Originally posted by ccodehelp
        have 'access' stored in char* a. I want to access a variable name constructed from it. like I am appending _func to all these variables, I actually want to access access_func.
        There is no access to the variable name at run time. Everything has been converted to binary. You can't even tell what language the program wwas written in.

        Comment

        Working...