Demonstrate the use for permanent and temporary storage : Static « Data Type « C / ANSI-C






Demonstrate the use for permanent and temporary storage

#include <stdio.h>

int main() {
    int i;
    for (i = 0; i < 3; ++i) {
        int temporary = 1;
        static int permanent = 1;

        printf("Temporary %d Permanent %d\n",temporary, permanent);
        ++temporary;
        ++permanent;
    }
    return (0);
}


           
       








Related examples in the same category

1.Static versus automatic variables
2.Define static variable inside function
3.Find out the address of a static variable in a functionFind out the address of a static variable in a function
4.Define and use static variable