O'Reilly logo

C Primer Plus, Fourth Edition by Stephen Prata

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

ANSI C Function Prototyping

The traditional, pre-ANSI C scheme for declaring functions was deficient in that it declared a function's return type, but not its arguments. Let's look at the kinds of problems that arise when the old form of function declaration is used.

The following pre-ANSI declaration informs the compiler that imin() returns a type int value:

int imin();

However, it says nothing about the number or type of imin()'s arguments. Therefore, if you use imin() with the wrong number or type of arguments, the compiler doesn't catch the error.

The Problem

Let's look at some examples involving imax(), a close relation to imin(). Listing 9.4 shows a program that declares imax() the old-fashioned way, and then uses imax() incorrectly. ...

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