Page t030, go to NEXT,
PREVIOUS, INDEX
Function Prototypes
Will this compile?
#include <stdio.h>
int main ()
{ printf ("%e newtons\n",
CoulombsLaw (1.6e-19, 1.6e-19, 5.3e-11));
return 0;
}
- types and number of arguments of functions are checked
- standard type conversion if necessary
- function return type is checked
- can be compilation warning if checks fail or conversion is not possible
- so also check compiler warnings
Will this compile?
#include <stdio.h>
extern double CoulombsLaw (double q1, double q2, double r);
int main ()
{ printf ("%e newtons\n",
CoulombsLaw (1.6e-19, 1.6e-19, 5.3e-11));
return 0;
}
- extern keyword says that function is external and
needs to be included in the link step
- statement ends with ; where body would have been
C Course, 21-jan-1997,
Peter Klok,
pfk@hef.kun.nl