Working with variable variables

This is a discussion on Working with variable variables within the C Programming forums, part of the General Programming Boards category; First off, I apologize for my lack of skills (especially in the case where this solution is trivial). I need ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    1

    Working with variable variables

    First off, I apologize for my lack of skills (especially in the case where this solution is trivial). I need to work with a large number of enumerated variables, and know there has to be an easy way to do it without having to explicitly write it out.

    An example may be the following,

    Code:
    double pl1,pl2,pl3,...,pl40;
    
    for(i=1;i<41;i++) {
       ... 
       intermediate code that is different for each value of i and determines the values of 'd'
       ...
       pl#= d;  //where # is whatever the current value of i is
    }
    
    ...
    Thanks! (Thanks even more if you can include a simple example of how I would do this!)

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    Do you mean that you haven't learnt arrays yet? If not, what's stopping you?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  2. Reading Separate Digits as Variables
    By linuxpyro in forum C Programming
    Replies: 7
    Last Post: 09-13-2006, 05:23 PM
  3. Beginner question
    By Tride in forum C Programming
    Replies: 30
    Last Post: 05-24-2003, 08:36 AM
  4. Need help
    By awkeller in forum C Programming
    Replies: 2
    Last Post: 12-09-2001, 02:02 PM
  5. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 01:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21