Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this an appropriate function definition?

Tags:

c

struct

My professor provides the function definition in our homework so that we do the assignment the way she wants. The definition she provided looks like this;

void outputStudents(struct student [], int size)

Usually she provides the names of the variables, for grading purposes, so I wanted to be sure. Do I need to change the declaration to include a name for the student object, such as

void outputStudents(struct student classroom[], int size)

or is there a way to access it the way it's written?

Sorry if this seems like an obvious question, but structs and pointers are throwing me for a loop (no pun intended), so I want to make sure before I change anything. She does make mistakes sometimes, so its hard to tell if I'm just confused, or if there's an error in the problem.

Edit: Ok, thanks guys. I understand that variables can have any name, but like I mentioned, usually she provides us with the exact function header should say(and takes off points if we change it unnessesarily), for grading purposes since she and the other two TAs look at hundreds of these a week. So I wanted to be sure that I wasn't overlooking something.

like image 492
Jacqlyn Avatar asked Feb 15 '23 15:02

Jacqlyn


2 Answers

Names of arguments can be omitted from the declaration (only the types matter). When you actually implement it, you must of course name the argument in order to use it.

like image 55
Arkku Avatar answered Feb 27 '23 00:02

Arkku


Argument name will be important only when implementing. In declaration they can be ignored because there the type is most important thing. You have to assign a name to the argument to be able to use it of course.

like image 28
Zegar Avatar answered Feb 26 '23 23:02

Zegar