diff --git a/ChangeLog b/ChangeLog index 40fd64f..5ff6705 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2024-10-30 Mert Gör + * c-basic/C.pdf: Global variable scope page 26 + * c-basic/scope.c (foo): same variable different scopes * c-basic/C.pdf: page 25,end of the page diff --git a/c-basic/global_scope.c b/c-basic/global_scope.c new file mode 100644 index 0000000..10a8f2e --- /dev/null +++ b/c-basic/global_scope.c @@ -0,0 +1,19 @@ +#include + +int main() +{ + int a; + + a = 10; + + { + int a; + + a = 20; + printf("%d\n", a); // 20 + } + + printf("%d\n", a); // 10 + + return 0; +} diff --git a/c-basic/scope.c b/c-basic/scope.c index 67e4a58..bcdd335 100644 --- a/c-basic/scope.c +++ b/c-basic/scope.c @@ -3,9 +3,7 @@ void foo() { int a; - { int a; - } } int main()