hello i m suppose to do this program which should pass array of ptrs to a structure intilise and put student info in each array i did most of it but now i got problem coz i cant just pass address of structure since its an array of ptrs to a structure you cant do &str since that will work on one structure only anyways here is the code
#include <stdio.h>
#define CSIZE 4
typedef struct Names {
char SzFirst[100];
char SzLast[100];
}Family;
typedef struct Student {
Family Handle;
float Grade[3];
float Average;
}student;
void EatLines() {
while(getchar()!='\n')
continue;
}
void FillArr(student **std,int Size) {
float sum=0;
for(int i=0;i<Size;i++) {//Fill info
printf("Please enter Your first and Last name");
scanf("%s %s",std[i]->Handle.SzFirst,std[i]->Handle.SzLast);
EatLines();
printf("Please enter 3 scores of some of your exams");
for(int x=0;x<sizeof std[i]->Grade/sizeof std[i]->Grade[0];x++) {
scanf("%f",&std[i]->Grade[x]);//lol weird code :P
sum+=std[i]->Grade[x];
}
EatLines();
std[i]->Average= sum / sizeof std[i]->Grade/sizeof std[i]->Grade[0];//average=sum/howmany :P
sum=0;//reset sum to 0 so we preform some average again on next struct :P
}
}
void ShowArr(student **std,int Size) {
for(int i=0;i<Size;i++)
printf("Student num %d name %s %s and his average score is %d",
i+1,std[i]->Handle.SzFirst,std[i]->Handle.SzLast,std[i]->Average);
}
int main(void)
{
student std[CSIZE];
FillArr(&std,sizeof std/sizeof std[0]);
ShowArr(&std,sizeof std/sizeof std[0]);
return 0;
}