Tutorial by Examples

An identifier has block scope if its corresponding declaration appears inside a block (parameter declaration in function definition apply). The scope ends at the end of the corresponding block. No different entities with the same identifier can have the same scope, but scopes may overlap. In case o...
#include <stdio.h> /* The parameter name, apple, has function prototype scope. These names are not significant outside the prototype itself. This is demonstrated below. */ int test_function(int apple); int main(void) { int orange = 5; orange = test_function(oran...
#include <stdio.h> /* The identifier, foo, is declared outside all blocks. It can be used anywhere after the declaration until the end of the translation unit. */ static int foo; void test_function(void) { foo += 2; } int main(void) { foo = 1; test_functi...
Function scope is the special scope for labels. This is due to their unusual property. A label is visible through the entire function it is defined and one can jump (using instruction gotolabel) to it from any point in the same function. While not useful, the following example illustrate the point: ...

Page 1 of 1