Global variables always have an external storage scope. Thus global variables can be accessed from other modules using 'extern' keyword.

Static variables have a local scope and can never be accessed from outside. A static variable has a file scope when declared outside the functions in a program and function scope when declared inside a function (including main function). Example:


static int static_1;/*File Scope*/

int add_user(char *username)
  static int user_count = 0;/*Function scope*/

You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

data types, storage classes, volatile variable, external vs static, global vs static variable, register vs auto variable, const, sizeof void,

# C Programming Language (Prentice Hall Software)
# Let Us C Paperback - 2006 by Yashavant Kanetkar
# Understanding and Using C Pointers Core techniques for memory management
# Data Structures Using C and C++ Paperback - 1998
# Data Structures In C Paperback - August 11, 2008 by Noel Kalicharan