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:

Sample.c

static int static_1;/*File Scope*/

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

About our authors: Team EQA

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

#