What is the difference between declaring a variable and defining a variable?
Declaration of a variable in C hints the compiler about the type and size of the variable in compile time. Similarly,declaration of a function hints about type and size of function parameters. No space is reserved in memory for
any variable in case of declaration.
Example: int a;
Here variable 'a' is declared of data type 'int'Defining a variable means declaring it and also allocating space to hold it.
We can say "Definition = Declaration + Space reservation".
No comments:
Post a Comment