i am a little confused with the difference between declaring & defining a variable and a function int x; is supposed to be defining a variable whereas externint x; is considered to be declaring a variable.i am not able to get the logic.
Also can anyone give me a proper explanation of use of extern with variables and functions...As far as i know extern is added implicitely by the compiler to any function declaration.Dows it mean that that a function declared in 1 file can be accessed in other file????but this doesnt seem to work out for me
The extern keyword declares a variable or function and specifies that it has external linkage (its name is visible from files other than the one in which it's defined).
declaring a variable tells the compiler (or w/e you're using) what type the variable will be (int, char, double etc.) and that you will be using this variable later on in the program.
Defining a variable just tells the compiler what the variable is equal to.
an example of both would be:
Declaring - int x
Defining - x=5