Is this a suitable function definition?

My professor provides a definition of a function in our homework so that we complete the task the way it wants. The definition she provided is as follows:

void outputStudents(struct student [], int size)

It usually provides variable names for sorting purposes, so I wanted to be sure. I need to change the declaration to include a name for the student object, e.g.

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

or is there a way to access him as he wrote?

Sorry if this seems like an obvious question, but structures and pointers throw me in a loop (no pun intended), so I want to make sure before changing anything. Sometimes she makes mistakes, so it's hard to say if I'm embarrassed, or if there is a mistake in the problem.

Edit: Ok, thanks guys. I understand that variables can have any name, but, as I already mentioned, it usually provides us with the exact function header, which it should say (and removes points if we change it invisibly), for evaluation purposes, since it and the other two TAs look at hundreds of them per week. Therefore, I wanted to be sure that I did not notice anything.

+4
source share
4 answers

The name of the argument will be important only when implemented. They can be ignored in the declaration because the type is the most important. You must assign a name to the argument in order to be able to use it, of course.

+2
source

( ). , , , , .

+5

: ( )

void outputStudents(struct student [], int ); //note the ; at end of statement 

. (, )

( , ( ))

void outputStudents(struct student classroom[], int size)   
{   
    //do stuff here...
}  

. ( void)

. C, ​​, ( ) . : , . , : , . . ( / , , , :)

+1

, struct. -, , .

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

or

void outputStudents(struct student *classroom, int size)

match.

0
source

All Articles