home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C by Discovery (4th Edition)
/
C_By_Discovery_4th_Edition.tar
/
C_By_Discovery_4th_Edition
/
_DISK_
/
ch8
/
static.c
< prev
Wrap
C/C++ Source or Header
|
2005-06-16
|
723b
|
35 lines
/* static.c
*
* Synopsis - Outputs two integer values.
*
* Objective - Illustrates static variables.
*/
/* Include Files */
#include <stdio.h>
/* Function Prototypes */
int increment( void );
/* PRECONDITION: none.
*
*POSTCONDITION: Increments a static local variable and
* returns its incremented value.
*
*/
int main( void )
{
printf( "%d\n", increment() ); /* Note 2 */
printf( "%d\n", increment() );
return 0;
}
/*******************************increment()*********************/
int increment( void )
{
static int number = 0; /* Note 1 */
return ( ++number );
}