Arrays are actually always passed by pointer, so this is not so hard. If your declaration looks like this:
Code:
struct example ray[3];
You can use either of these in a function prototype:
Code:
void testfunc (struct example *ray);
void testfunc (struct example ray[3]);
Here's a little demo:
Code:
#include <stdio.h>
struct example {
char *ptr;
int ID;
};
/* this needs to be global since testfunc does not copy, it just links */
char data[3][8]={"one", "two", "three"};
void testfunc (int size, struct example ray[size]) {
int i, x=0;
for (i=0;i<size;i++) { /* populate the array */
ray[i].ptr=data[x]; x++;
ray[i].ID=i+1;
if (x>2) x=0; }
}
int main() {
int num = 6, i;
struct example ray[num];
testfunc(num,ray);
/* now back in main... */
for (i=0;i<num;i++) printf("%d %s\n",ray[i].ID,ray[i].ptr);
return 0;
}
Output:
1 one
2 two
3 three
4 one
5 two
6 three
Again, testfunc could have used *ray instead of ray[size].