Hi,

I am have trouble in Array of pointers to structure.
I have defined as structure.
typedef struct
{
char * name[5];
int number;
}mystr;

I have defined an array of pointers to this structure.( is this correct ?)
mystr (* myptr)[5];

To fill the values, i have to pass this to a function, fill it and return it back.
Now I have to
1) pass this array of pointers to structure as an arugument to a function ( i dont know how?)
2) get it filled up ( i guess i can do)
3) return the array of pointers to structure to the calling function ( i dont know this either.)

I am getting rather confused to make a function definition for this.
Hope somebody could through some light abt this.
Thanks.
Vib.

To pass that array. Note: name in the structure is an array is 5 pointers, not a character array. So that structure can hold up to 5 strings (names).

typedef struct
{
char * name[5];
int number;
}mystr;

int foo(mystr* myptr[5])
{
    return 0;
}

int main()
{
    mystr* myptr[5];
    foo(myptr);


}

2) full it up as you normally would in main()

3) Not necessary ot specifically return the array back to main because when its changed in foo() it will also be changed in main().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.