#include <stdio.h>

int count = 0; // [전역 변수] 모두가 공유하는 칠판

void check_wifi() {
    // 와이파이 체크하는 함수를 누군가(혹은 미래의 나) 만들었습니다.
    // 그런데 여기서 실수로 'count'라는 이름을 또 써버렸네요?
    for (count = 0; count < 5; count++) { 
        printf("와이파이 신호 확인 중...%d\n",count);
    }
}

int main() {
    count = 100; // 중요한 데이터를 100으로 설정해둠
    
    check_wifi(); // 와이파이만 체크하고 오라고 시킴
    
    // 나는 분명 100을 넣었는데, 갑자기 5가 출력됨!
    // 범인을 찾으려면 check_wifi 함수 안을 뒤져봐야 함.
    printf("현재 카운트: %d\n", count); 
    
    return 0;
}

Embed on website

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