Function Prototype (declaration)
In C, functions first have to be declared before they are used.
#include <stdio.h>
int myFunctionPrototype(int x, char chr, float num);
int main(){
int OperationResult;
OperationResult = myFunctionPrototype(32, 'C', 34.2);
return 0;
}
int myFunctionPrototype(int x, char chr, float num){
// do some stuff
return result;
}
A prototype let's the compiler know about:
- The return data type. >>
int
- The arguments list (and their data type). >>
int x
,char chr
,float num
- The order of arguments being passed to the function. >> First an
int
, then achar
and finally afloat