September 2001
Beginner
970 pages
23h 20m
English
So far, these programs have used the standard printf() function. Listing 2.3 shows you how to incorporate a function of your own—besides main()—into a program.
/* two_func.c -- a program using two functions in one file */
#include <stdio.h>
void butler(void); /* ISO/ANSI C function prototyping */
int main(void)
{
printf("I will summon the butler function.\n");
butler();
printf("Yes. Bring me some tea and writeable CD-ROMS.\n");
return 0;
}
void butler(void) /* start of function definition */
{
printf("You rang, sir?\n");
}
|
The output looks like the following:
I will summon the butler function. You rang, sir? Yes. Bring me some tea and writeable CD-ROMS.
The butler() ...
Read now
Unlock full access