Understanding the "extern" Keyword in CBy extern keyword, we mean external in C programming language. We will understand the extern keyword with a small example scenario where two variables must be accessed in two different files. In this case, the extern keyword comes handy. While defining a function or a variable in the C programming language, the memory is allocated for the variable, or the function declared. It helps us extend the visibility of the functions and the variables in the C programming language; hence it is named as an external keyword in short read as an extern. Declaration of a variable or a function is no big deal, but allocating sufficient memory for them is a critical task, and the extern keyword is used in such problems. Variables in C -1Output: b Variables in C -2Output: 221,231 221,332 221,433 Variables in C -3Output: Compiles without any error Extern keywordOutput: /usr/bin/ld: cannot open output file a.out: Permission denied collect2: error: ld returned one exit status The below codes compile successfully and don't throw any errors when compiled. Next TopicBanker's Algorithm in C |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India