A short introduction

This blog is aimed to carry out a healthy discussion on today's technology.It's objective is to keep you up-to-date with the latest news updates in the field of programming, electronics and information technology, the three pillars of our growing technology.

Monday 15 June 2015

Difference between declaration and definition in the C language.



Hii friends,
In my this post I want to share wid you something on one of the most famous middle-level programming languages, C language.In C language, we generally come across the use of declaration and definition whether of a function, a variable or may it be structures.In case of functions and other user-defined c-tokens, this difference is clear-cut.But when it comes to the variable, both looks the same.So, the meaning of definition and declaration for variables is as follows:

Declaration: It specifies the type and name of the variable.

Definition: It specifies the type and name as well as the memory location on computer memory where the variable has been allocated storage.

Example:
                    int name;
It is a declaration of variable name.

                   extern int name;
It is a definition of variable name (excluding the case of multiple-file program).



No comments:

Post a Comment