From 293bc9b7ecce5427ae38cf58ffe3bdf44af351b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20G=C3=B6r?= Date: Fri, 1 Nov 2024 07:55:47 +0300 Subject: [PATCH] file scope example --- ChangeLog | 4 ++++ c-basic/file_scope.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 c-basic/file_scope.c diff --git a/ChangeLog b/ChangeLog index 5ff6705..c92528c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2024-11-01 Mert Gör + + * c-basic/file_scope.c (foo): file scope example + 2024-10-30 Mert Gör * c-basic/C.pdf: Global variable scope page 26 diff --git a/c-basic/file_scope.c b/c-basic/file_scope.c new file mode 100644 index 0000000..6947037 --- /dev/null +++ b/c-basic/file_scope.c @@ -0,0 +1,18 @@ +#include + +int a; + +void foo() +{ + a = 10; +} + +int main () +{ + a = 20; + printf("%d\n", a); // a = 20; + foo(); + printf("%d\n", a); // a = 10 + + return 0; +}