Demonstrates automatic and static local variables. - C Function

C examples for Function:static

Description

Demonstrates automatic and static local variables.

Demo Code

#include <stdio.h>

void func1(void)
{
    static int x = 0;
    int y = 0;/*w  ww.j a  v a  2s .co  m*/

    printf("x = %d, y = %d\n", x++, y++);
}

int main( void ){
   int count;

   for (count = 0; count < 20; count++)
   {
        printf("At iteration %d: ", count);
        func1();
   }

   return 0;
}

Related Tutorials