variable name from string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ice8595
    New Member
    • Mar 2007
    • 13

    #1

    variable name from string

    I'm wondering if there's a way of creating a variable with its name coming from a string.

    The reason I need to do this is because I have to create a bunch of xml files (each defined by the user) at runtime. I kept them in an array, but I have no way of differentiating between them. I need to input different data into specific files, and right now everything is just writing to the last file I created.

    Any ideas??

    Thanks
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    HI,
    You cant variables at run time with the names passed to u as argument.
    You can change only the variable values.

    Thanks
    Raghuram

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      But you could create a structure containing the name of the data and the value in order to allow you to identify the data once read.

      Code:
      struct data {
          char *name;
          int value;
      };

      Comment

      • ice8595
        New Member
        • Mar 2007
        • 13

        #4
        thanks for your help

        in the end I just decided to set a limit to the number of files and initiate them ahead of time

        Comment

        Working...