Multiple Arguments
A function can have more than one argument. In the function call, you just separate the arguments with commas:
n_chars('R', 25);
This passes two arguments to the function n_chars(), which will be defined shortly.
Similarly, when you define the function, you use a comma-separated list of parameter declarations in the function header:
void n_chars(char c, int n) // two arguments
This function header states that the function n_chars() takes one type char argument and one type int argument. The parameters c and n are initialized with the values passed to the function. If a function has two parameters of the same type, you have to give the type of each parameter separately. You can’t combine declarations the way you can when you ...
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