Extern Keyword


In C programming, the 'extern' keyword is used to declare a variable or function that is defined in another source file or module.

It is used to indicate that the variable or function is defined externally and can be accessed by other source files in the program.

Here's an example of using the 'extern' keyword to declare a variable:


extern int x;

    

In this example, the 'extern' keyword is used to declare a variable named 'x' without defining it.

The actual definition of the variable can be found in another source file. This allows other source files to access and use the variable 'x' without redeclaring it.

The 'extern' keyword is also commonly used in header files to declare global variables or functions that are defined in the corresponding source file.

It provides a way to share variables and functions across multiple files in a program and promotes modularity and code reusability.

Loading...

Search