# How to pass a string\[string\] array to a function

**URL:** <https://community.freefem.org/t/how-to-pass-a-string-string-array-to-a-function/2449>\
**Category:** General Discussion\
**Created:** [May 9, 2023, 1:01pm UTC](https://community.freefem.org/t/how-to-pass-a-string-string-array-to-a-function/2449 "2023-05-09T13:01:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Christian](https://community.freefem.org/u/Christian)\
**Post date:** [May 9, 2023, 1:01pm UTC](https://community.freefem.org/t/how-to-pass-a-string-string-array-to-a-function/2449/1 "2023-05-09T13:01:29Z")

</div>

Hello everyone,  
I was tring to use as input of an external funciton a string[string] array but for some reasons, it does not seemes to be possible. FreeFEM does not give any allert of error, but it does not give any output. Here below is reported a trivial example just to highlight the problem.

Thank you in advance!  
Christian

[readstringarray.idp](https://community.freefem.org/uploads/short-url/lTd57TEehtAcMQLpacN33auNHUP.idp) (130 Bytes)  
[stringstringarrayexample.edp](https://community.freefem.org/uploads/short-url/yGfjchb15CrH2dtbQQOVqpGVa3C.edp) (603 Bytes)

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 9, 2023, 1:05pm UTC](https://community.freefem.org/t/how-to-pass-a-string-string-array-to-a-function/2449/2 "2023-05-09T13:05:47Z")

</div>

Your code does not run with an error message.

```auto
   20 : string givemecolor=readarray(arrayofstrings); The identifier givemecolor exists 
 	  the existing type is <PPNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE>
 	  the new type is <PPNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE>

```

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 9, 2023, 1:07pm UTC](https://community.freefem.org/t/how-to-pass-a-string-string-array-to-a-function/2449/3 "2023-05-09T13:07:20Z")

</div>

Furthermore, if you remove the second definition of `givemecolor`, and switch in `readstringarray.idp` from an input of type `string[string]` to an input of type `string[string]&`, then the code runs OK.

```auto
$ FreeFem++ stringstringarrayexample.edp -v 0
CIAO1
The color of the fruitis: yellow
CIAO2

```

---

<div class="post-metadata">

**Author:** ![Christian](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Christian](https://community.freefem.org/u/Christian)\
**Post date:** [May 9, 2023, 1:17pm UTC](https://community.freefem.org/t/how-to-pass-a-string-string-array-to-a-function/2449/4 "2023-05-09T13:17:11Z")

</div>

Sorry! I forgot to delete the code line “string givemecolor=readarray(arrayofstrings);” at the start!  
Thanks for the tip, it works perfectly now!
