what is the difference definition and declaration in C language.how the memory will be allocated.can tou explain me with an example
What is the difference definition and declaration in C language?
A definition is where a variable will actually have memory allocated for it and initialized. A declaration is where, in a header file, you give the variable's type, so that several modules may access it correctly.
extern int g_nMyCounter; //declaration (usually in a header file)
int g_nMyCounter = 0; //definition (usually in a .c or .cpp file)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment