Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Scope-modifiers/C/scope-modifiers-1.c
Normal file
24
Task/Scope-modifiers/C/scope-modifiers-1.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
int a; // a is global
|
||||
static int p; // p is "locale" and can be seen only from file1.c
|
||||
|
||||
extern float v; // a global declared somewhere else
|
||||
|
||||
// a "global" function
|
||||
int code(int arg)
|
||||
{
|
||||
int myp; // 1) this can be seen only from inside code
|
||||
// 2) In recursive code this variable will be in a
|
||||
// different stack frame (like a closure)
|
||||
static int myc; // 3) still a variable that can be seen only from
|
||||
// inside code, but its value will be kept
|
||||
// among different code calls
|
||||
// 4) In recursive code this variable will be the
|
||||
// same in every stack frame - a significant scoping difference
|
||||
}
|
||||
|
||||
// a "local" function; can be seen only inside file1.c
|
||||
static void code2(void)
|
||||
{
|
||||
v = v * 1.02; // update global v
|
||||
// ...
|
||||
}
|
||||
8
Task/Scope-modifiers/C/scope-modifiers-2.c
Normal file
8
Task/Scope-modifiers/C/scope-modifiers-2.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
float v; // a global to be used from file1.c too
|
||||
static int p; // a file-scoped p; nothing to share with static p
|
||||
// in file1.c
|
||||
|
||||
int code(int); // this is enough to be able to use global code defined in file1.c
|
||||
// normally these things go into a header.h
|
||||
|
||||
// ...
|
||||
Loading…
Add table
Add a link
Reference in a new issue