Passing struct to function
c, function, struct
Solution
The line function implementation should be:
void addStudent(struct student person) {
}
`person` is not a type but a variable, you cannot use it as the type of a function parameter.
Also, make sure your struct is defined before the prototype of the function `addStudent` as the prototype uses it.
Problem
I'm a new C programmer and I wanted to know how I can pass a `struct` through to a function. I'm getting an error and can't figure out the correct syntax to do it. Here is the code for it.... Struct: ``` struct student{ char firstname[30]; char surname[30]; }; struct student person; ``` Call: ``` addStudent(person); ``` Prototype: ``` void addStudent(struct student); ``` and the actual function: ``` void addStudent(person) { return; } ``` Compiler errors: line 21: warning: dubious tag declaration: struct student line 223: argument #1 is incompatible with prototype: