# structure pointer array as function parameters

**URL:** <https://community.unix.com/t/structure-pointer-array-as-function-parameters/290194>\
**Category:** Programming\
**Created:** [June 21, 2011, 12:50pm UTC](https://community.unix.com/t/structure-pointer-array-as-function-parameters/290194 "2011-06-21T12:50:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mscoder](https://community.unix.com/letter_avatar/mscoder/32/5_5575768a8748004e209b776fc1b2916d.png) [@mscoder](https://community.unix.com/u/mscoder)\
**Post date:** [June 21, 2011, 12:50pm UTC](https://community.unix.com/t/structure-pointer-array-as-function-parameters/290194/1 "2011-06-21T12:50:09Z")

</div>

if i create an array of pointers to a structure "struct node" as:

```nohighlight
struct node *r[n];

```

and create "n" number of "linked lists" and assign it to the various struct pointers r [i]using some function with a return type as structure pointer as:

```nohighlight
r=multiplty(.......) /*some parameters*/

```

is it wrong to then use the individual array members like r[0],r[1] (which are now pointers to various linked lists) etc. as parameters to a function that accept a structure pointers as parameter like::

```nohighlight
struct node *add_result;
add_result= add(r[o],r[1]);/*add() returns a struct pointer,no error shown in compilation */

```

the programme goes into an infinite loop whenever i try to display the list pointed by add\_result..the functions add() and display() work fine in other cases..

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [June 21, 2011, 12:56pm UTC](https://community.unix.com/t/structure-pointer-array-as-function-parameters/290194/2 "2011-06-21T12:56:43Z")

</div>

There's no problem with that syntax, whatever is going wrong is something else.

Seeing the contents of these functions could be instructive.

---

<div class="post-metadata">

**Author:** ![shamrock](https://community.unix.com/letter_avatar/shamrock/32/5_5575768a8748004e209b776fc1b2916d.png) [@shamrock](https://community.unix.com/u/shamrock)\
**Post date:** [June 21, 2011, 4:10pm UTC](https://community.unix.com/t/structure-pointer-array-as-function-parameters/290194/3 "2011-06-21T16:10:18Z")

</div>

> [@mscoder](#):
>
> the programme goes into an infinite loop whenever i try to display the list pointed by add\_result..the functions add() and display() work fine in other cases..

Can you post this piece of code...seems like the condition for stopping the display pointed by add\_result may not be right.
