I am trying to understand why this 3rd argument in the scanf() function needs an ampersand but not the 2nd one, without the ampersand I get an error saying "Argument 3 of scanf() is not a pointer".
struct person {
int age;
float weight;
char name[30];
};
for(i = 0; i < n; ++i)
{
printf("Enter name of person %d and age respectively: ", i);
// To access members of 1st struct person,
// ptr->name and ptr->age is used
// To access members of 2nd struct person,
// (ptr+1)->name and (ptr+1)->age is used
scanf("%s %d", (ptr+i)->name, &(ptr+i)->age);
}
I just want to understand why that's happening and I can't really get the grasp of the arrow pointer operator as well.