I'm doing an exercise where I have to load student data. I do it using functions using structures. I have a syntax problem of how to save a data in a nested structure.
I tried to do it like this:
a[i].fe.dia;
And I get the following error:
request for member 'dia' in '((+ (((unsigned int) i) * 144u)) + a) - > students :: faith', which is of non-class type 'date [2] '
and I also tried this way:
a.fe[i].dia;
and when I do it, I get the following error:
'faith' has not been declared
But in neither of the two ways does it work for me. I do not know if I'm doing it wrong or I lacked some statement or something to make it work.
struct fecha
{
int dia, mes, anio;
};
struct alumnos
{
int legajo [10];
char apnom [35];
char direc [40];
struct fecha fe [2]; /* fecha nacimiento y fecha ingreso institución */
int edad;
};
void carga_alu (struct alumnos [ ], int *);
int main()
{
struct alumnos alum[100];
int cantalum;
carga_alu(alum,&cantalum);
system("PAUSE");
return 0;
}
void carga_alu (struct alumnos a[ ], int *c)
{
char rta='s';
int i=0,cont=0;
while (rta=='s')
{ printf("Ingrese el nombre y apellido del alumno \n");
gets(a[i].apnom);
printf("Ingrese el legajo del alumno \n");
scanf("%d",&a[i].legajo);
printf("Ingrese la direccion del alumno \n");
gets(a[i].direc);
printf("Ingrese la fecha de nacimiento del alumno: DIA \n");
scanf("%d", &a[i].fe.dia);
printf("Ingrese la fecha de nacimiento del alumno: MES \n");
scanf("%d", &a[i].fe.mes);
printf("Ingrese la fecha de nacimiento del alumno: ANIO \n");
scanf("%d", &a[i].fe.anio);
printf("Ingrese la fecha de ingreso a la institucion del alumno: DIA \n");
scanf("%d", &a[i].fe.dia);
printf("Ingrese la fecha de ingreso a la institucion del alumno: MES \n");
scanf("%d", &a[i].fe.mes);
printf("Ingrese la fecha de ingreso a la institucion del alumno: ANIO \n");
scanf("%d", &a[i].fe.anio);
cont=cont+1;
i=i+1;
printf("Desea cargar otro alumno? S o N");
scanf("%c",rta);} }