Something like this?#include <stdio.h>
struct tag /* global structure definition */
{
int element;
int counter;
char somestuff;
};
struct tag* my_subroutine(struct tag st_lst[], int n);
struct tag st_list[4];
int main(void)
{
//struct tag st_list[4];
//st_list call
my_subroutine((struct tag *)&st_list, 4); //call subroutine to create and initialize multiple structures
printf("%d %d\n", st_list[0].element, st_list[0].counter);
if (st_list[0].element == 32)
; //do something cool;
if (st_list[3].counter == 0)
; //do something here;
// address all members of all structures...
return 0;
}
struct tag* my_subroutine(struct tag st_lst[], int n)
{
st_lst[0].element = 200;
st_lst[0].counter=99;
st_lst[3].element = 333;
//...
//naturally I'd wrap this in a for loop...
//...more code
return st_lst; /* return structures to main routine so it can see/modify contents */
}