| Formally... |
A function declaration in ANSI C has the form:
result-type function-name( parameter-list )
function-body
|
| Examples |
A function which has one integer as a parameter and returns an integer:
/* Declare the function : */
int times_two(int x) {
return x+x;
}
....
/* Use the function : */
printf("%d\n", times_two(8));
printf("%d\n", times_two(a));
|
/* tea_message does not return a result */
/* and has no parameters : */
void tea_message ( void ) {
printf("Time for tea!\n");
}
...
/* Display message : */
tea_message();
|
| ...previous | up (conts) | next... |