지역변수 정적변수

2024. 7. 4. 20:21정보처리,전산/Clang

반응형
#include <stdio.h>
#include <string.h>

void first(){
    int count =0;
    printf("%d",count++); //지역변수 count는 계속 0이된다
}
void second(){
    static int count =0;
    printf("%d",count++);

}
int main(){ //함수s1 다섯번 실행
    int i;
    for (i=0;i<5;i++){
        first();
    }

    printf("\n");
    for (i=0;i<5;i++){
        second();
    }
    
}

 

반응형

'정보처리,전산 > Clang' 카테고리의 다른 글

2진수를 10진수 16진수로 출력  (0) 2024.07.06
포인터 변수 **p  (0) 2024.07.06
struct 구조체  (0) 2024.06.30
문자열 변환 출력  (0) 2024.06.29
주소 배열 출력  (0) 2024.06.26