void storing(struct student * p, int count)
{
int i,j;
for ( i = 0; i < count; i++)
{
printf("the %d student's info\n", i+1);
printf("name:\n");
scanf("%s", p[i].name);
printf("age:\n");
scanf("%d", &((&p[i])->age));
printf("grade:\n");
scanf("%d", &(*(p+i).grade));
}
return;
}
I don't know why scanf
doesn't take &(*(p+i).grade)
? I know *(p+i) ≡ p[i]
, but I don't know why it just doesn't work here. I did similar thing with *(p+i)
in another code I written: *p.age = 10;
and it successfully writes the value into member age
.