How to declare variable in nested blocks with internal scope with C

1 Answer

0 votes
#include <stdio.h>

int n = 17;

int main() {
    extern int n; {
        int n = 100; {
            const unsigned n = 9381;
            printf("const unsigned n = %d\n", n);
        }
        printf("extern int n = %d\n", n);
    }
    
    printf("int n = %d", n);
     
    return 0;
}





/*
run:

const unsigned n = 9381
extern int n = 100
int n = 17

*/

 



answered Oct 6, 2021 by avibootz
...