Saturday, April 28, 2012

7.33

Here is a legal C program with a function variable:


Figure 7.45




Compare lines 6 and 8 of this code to the equivalent code of Figure 7.45 (lines 1 and 3). Why is this version of the code permitted? Why is it not required?

The function fun_var at line 6 is allowed because it has the same parameters as the gcd function it points to, and is essentially a pointer, and so it can store the address of another function with the same parameters

No comments:

Post a Comment