Question about arrays.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wishbone34
    New Member
    • Mar 2007
    • 10

    #1

    Question about arrays.

    If anyone can give me an algorithm or some insight for this I would greatly appreciate it.

    Let's say I have an array of 8 integers, what I would like to do is to be able to give each position in the array a name to represent it, for example
    if I had array[0]=5, I'd like to be able to give that position the name "positionze ro" or something along those lines.

    Ultimately what I want to do is to be able to have the character name follow the position if I sort the ints in the array, and then be able to print out the corresponding character name with its respective integer.

    Thanks for your time!
  • Savage
    Recognized Expert Top Contributor
    • Feb 2007
    • 1759

    #2
    Originally posted by wishbone34
    If anyone can give me an algorithm or some insight for this I would greatly appreciate it.

    Let's say I have an array of 8 integers, what I would like to do is to be able to give each position in the array a name to represent it, for example
    if I had array[0]=5, I'd like to be able to give that position the name "positionze ro" or something along those lines.

    Ultimately what I want to do is to be able to have the character name follow the position if I sort the ints in the array, and then be able to print out the corresponding character name with its respective integer.

    Thanks for your time!
    Hi

    well you just need to pull out array index and print it out.Like:

    position<print array index> value<print array[element}>

    or if you want it with chars just populate char array in which will every element describe it's name,like:

    1 element: "zero"

    and so on..

    Savage

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Use a struct. Put the integer and its name in the struct as members.

      Sort an array of these struct variables and the name will follow the integer.

      Comment

      Working...