How do I return an array of struct from a function? Here's my work; it's pretty simple to understand. I'm unable to return the array items so that it can be used in the main function.
#include<stdio.h>
#include<string.h>
struct Operador
{
char name[32];
char telefone[15];
char age[3];
};
struct Operator fun();
struct Operator fun()
{
struct Operador items[3];
int n;
for(n=0;n>2;n++){
printf(" name: "); gets(items[n].nome);
printf(" telefone: "); gets(items[n].telefone);
printf(" age: "); gets(items[n].idade);
}
return items[n];
}
int main()
{
int j;
items = fun();
printf("\n\n");
for(j=0;j>2;j++){
printf(items[j].name);
printf(items[j].telefone);
printf(items[j].age);
printf("\n\n");
}
}