September 1998
Intermediate to advanced
848 pages
20h 13m
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); /* ANSI C function prototyping */
/* pre-ANSI C uses void butler(); instead */
int main(void)
{
printf(I will summon the butler function.\n);
butler();
printf(Yes. Bring me some tea and writeable CD-ROMS.\n);[sr]
return 0;
}
void butler(void) /* start of function definition */
{
printf("You rang, sir?\n");
}
|
The output looks like this:
I will summon the butler function. You rang, sir? Yes. Bring me some tea and ...
Read now
Unlock full access