# String to Arrayname...?

**URL:** <https://forum.arduino.cc/t/string-to-arrayname/138949>\
**Category:** Programming\
**Created:** [January 12, 2013, 10:08pm UTC](https://forum.arduino.cc/t/string-to-arrayname/138949 "2013-01-12T22:08:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [January 12, 2013, 10:08pm UTC](https://forum.arduino.cc/t/string-to-arrayname/138949/1 "2013-01-12T22:08:03Z")

</div>

Hey there!  
it might be stupid, but im kinda new to arduino or C++. I tried my best with google & friends and my brain.

i want to store the name of an array in a string, so that i can manipulate it later.

```cpp
String menu_name = "main_menu";
String main_menu[] = {"item1", "item2", "item3"};

dosomething(menu_name);

void dosomething(String bla[]) {
 // do something with the "main menu" array
}

```

can anyone help with the kind of thing i'm looking for? Or tell me where i'm wrong?  
thanks in advance!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [January 12, 2013, 10:12pm UTC](https://forum.arduino.cc/t/string-to-arrayname/138949/2 "2013-01-12T22:12:19Z")

</div>

When the compiler gets done, all variable names (including arrays) have been mapped to addresses. Only the addresses are known. Trying to do something to an array, based solely on its name at run time, is NOT possible.

Using the String class is not advisable, either. Passing an array of String objects to the dosomething() function doesn't seem reasonable, either.

---

<div class="post-metadata">

**Author:** ![Arrch](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Arrch](https://forum.arduino.cc/u/Arrch)\
**Post date:** [January 12, 2013, 11:22pm UTC](https://forum.arduino.cc/t/string-to-arrayname/138949/3 "2013-01-12T23:22:24Z")

</div>

As Paul said, the Arduino has no idea that the array you've created is called "main menu"

The closest you can get is to create a hashtable which stores the character string and the array, but it's not recommended considering the limited SRAM on the Arduino. There is usually a better way to accomplish your overall goal.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [January 13, 2013, 7:47pm UTC](https://forum.arduino.cc/t/string-to-arrayname/138949/4 "2013-01-13T19:47:35Z")

</div>

aha! thanks a lot! i will work further and look for a workaround... cheers!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 8:02pm UTC](https://forum.arduino.cc/t/string-to-arrayname/138949/5 "2021-05-05T20:02:22Z")

</div>

Closed on May 5, 2021, 8:02pm UTC


