#include <stdio.h>

void SimpleFunc(void)
{
    static int num1=0; // 지역 num1=2
    int num2=0; // num2=0
    num1++, num2++; // num1=3, num2=1
    printf("static: %d, local:%d \n", num1,num2);
}

int main(void)
{
    int i;
    for(i=0; i<3; i++) // 3 반복
        SimpleFunc(); // 함수 호출
    return 0;
}

// - 0 초기화 
// - 모든 함수에서 사용
// - 프로그램 시작~끝 살아있다

// - 랜덤값 초기화 -> (static) 0 초기화
// - 선언된 함수에서 사용 
// - 선언된 지역 내 살아있다 -> 선언된 위치~ 프로그램 끝 살아있다

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: