为什么地址运算符不需要stud-> names.firstName? 但是需要地址运算符& stud-> studentid?为什么在scanf中不需要address操作符?
struct student {
struct
{
char lastName[10];
char firstName[10];
} names;
int studentid;
};
int main()
{
struct student record;
GetStudentName(&record);
return 0;
}
void GetStudentName(struct student *stud)
{
printf("Enter first name: ");
scanf("%s", stud->names.firstName); //address operator not needed
printf("Enter student id: ");
scanf("%d", &stud->studentid); //address operator needed
}
的[为什么scanf()的需要和在某些情况下,运营商,而不是其他人?](HTTP可能重复://计算器.com/questions/3440406/why-does-scanf-need-operator-in-some-cases-and-not-others) –