i'm trying to pass an array of stract to a function, but i just gave up. i´m trying to store data inside the structure function "fun()", so i can later pull up the data in function lo(); when ever i need too.
#include<stdio.h>
#include<string.h>
struct Operador
{
char nome[32];
char telefone[15];
char idade[3];
};
struct Operador* fun( ) {// im using this function to store the data
struct Operador* pItems = malloc(3 * sizeof(struct Operador));//is it necessary to use malloc
int n;
printf(" give nome: ");
scanf("%s", pItems->nome);
printf(" give telefone: ");
scanf("%s", pItems->telefone);
printf(" give age: ");
scanf("%s", pItems->idade);
return pItems;
}
//*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-
void lo(struct Operador pItems)//and this function to display the data
{
struct Operador Items = pItems;
int j;
printf("\n\n");
printf("Name is: %s \n", Items->nome);
printf("telefone is: %s \n", Items->telefone);
printf("age is: %s \n", Items->idade);
printf("\n\n");
return pItems;
}
main()
{
fun(); //here i call out the function for the user to type in information
printf("\n\n click any key to see data");
system("pause");
lo(); // and this function is supposed to display information
}