O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Functions That Take Arguments

The next logical evolution of your user-defined functions is to have them take arguments. Most C functions take arguments, like isalpha(), which expects a character to be passed to it. To have your functions take arguments, you need to define them—both in the prototype and in the formal definition—with the type of arguments expected:

void my_func (int age, int year);
int main (void) {
   // Call my_func().
}
void my_func (int age, int year) { ...

When calling a function that takes arguments, you need to then pass it the appropriate values. As you've already seen, there are many ways of doing this, from passing literal values to variable values to the results of calculations. Each of these function calls are ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required