This isn't specific to structs
.
In function prototypes (forward declarations), you are allowed to omit the name, e.g.
int foo(int, char*, struct student);
A forward declaration exists for callers of the function. So here, the compiler really only needs to know what type of parameters to expect. Considering that the prototype (often found in a header file) serves as documentation on how to call said function, I strongly recommend that you include the names. Otherwise, you're likely to get smacked by the dev across the hall!
Your confusion may come from the syntax struct student
. Keep in mind that the type's name is both words here, struct student
. You can't refer to it in any other way, unless you use a typedef
.
However, the parameter name is required for the actual function definition. Otherwise, how would you refer to the parameter?!
int foo(int number, char* name, struct student record) {
}
I should also point out that it is rare that one actually wants to pass a struct
(by value) to a function. More likely is the case that you pass a pointer to a struct
:
int foo(int number, char* name, struct student *record_ptr) {
}