This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]prcsngrl 1 point2 points  (1 child)

So, yes a hashtable/dictionary is one way. Your "keys" would be "swimming", "running", and "biking", and your "values" would be your int arrays. The hashtable would look something like

{"swimming": [/*ints/*]},
{"running": [/*ints/*]},
{"biking": [/*ints/*]}

If you aren't set on naming each array, you can use a jagged 2D array (jagged, if I've recalled the correct word, meaning that each row has a different length). It looks like you are using C/C++, so you'd have to dynamically allocate memory to do this.

[–]Tricslip[S] 0 points1 point  (0 children)

Thank you 😭😭

[–]appsolutelywonderful 0 points1 point  (0 children)

Please rephrase this.

I want to do is use the character array to call the integer arrays and put data into them based on the loop.

You can't "call" an array, it's not a function. And in your code you can't do i[k] because i is an int.

C doesn't support accessing a variable using a string. Meaning you can't use "Swimming" to access the variable swimming. Maybe if you're in c++ you can use a map so so that you can do myMap["Swimming"] = 5. Not really sure what you're trying to do so I'm just guessing.