info:c_global_local
Differences
This shows you the differences between two versions of the page.
info:c_global_local [2010/01/14 11:13] – created moritz | info:c_global_local [2010/01/25 09:21] (current) – static inner vars moritz | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Variables in C ====== | ====== Variables in C ====== | ||
- | ===== static | + | ===== Static |
Test case: Code for c1.c: <code c># | Test case: Code for c1.c: <code c># | ||
Line 27: | Line 27: | ||
Compile with '' | Compile with '' | ||
+ | |||
+ | ===== Keyword Static in functions ===== | ||
+ | <code c># | ||
+ | |||
+ | void f() { | ||
+ | static int x; | ||
+ | printf(" | ||
+ | x = 5; | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | |||
+ | int main(void) { | ||
+ | f(); | ||
+ | f(); | ||
+ | return 0; | ||
+ | }</ | ||
+ | |||
+ | The code prints | ||
+ | 0 | ||
+ | 5 | ||
info/c_global_local.1263467623.txt.gz · Last modified: 2010/01/14 11:13 by moritz