Function Parameter List
A function’s parameter list can be empty but cannot be omitted. Typically we define a function with no parameters by writing an empty parameter list. For compatibility with C, we also can use the keyword void to indicate that there are no parameters:
void f1(){ /* ... */ } // implicit void parameter listvoid f2(void){ /* ... */ } // explicit void parameter list
A parameter list typically consists of a comma-separated list of parameters, each of which looks like a declaration with a single declarator. Even when the types of two parameters are the same, the type must be repeated:
int f3(int v1, v2) { /* ... */ } // errorint f4(int v1, int v2) { /* ... */ } // ok
No two parameters can have the same name. Moreover, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access