What is the meaning of definition in C language? What does the statement mean? What is the difference between them?

Source: Internet
Author: User

In the C language, for definitions and declarations, perhaps we are very familiar with, but not necessarily really understand!

Definition means: The definition is to create a (compiler) an object, to allocate a memory space for this object and name, that is, the name of the variable or object that we normally call, once this is a memory space match, then in the definition of this object or variable life cycle, The variable name created cannot be changed, and the location of the memory space will not change. Within a region (within a function, global), a name can only be defined once and cannot be defined repeatedly.

Meaning of the Declaration: the declaration has a twofold meaning

First meaning: Tell the compiler that the name has been matched to a piece of memory space, and that the variable or object used in the subsequent code is defined somewhere else.

Eg:extern int I:

The second meaning: Tell the compiler, this name I have scheduled, such as the most familiar function declaration: void Fun (int i,char c); At the very beginning, it means telling the compiler that the name has been scheduled, and that the other variables or objects in the subsequent code will no longer be able to use the name. Declarations can be repeated multiple times.

Key differences in definition and declaration:

The definition creates an object and allocates memory space, whereas the Declaration does not allocate memory space.

                                                    

-------Summary from the "C Language Depth Analysis"

What is the meaning of definition in C language? What does the statement mean? What is the difference between them?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.