What is the definition in C language? What is the meaning of the statement? What is the difference between them ?, Meaning difference

Source: Internet
Author: User

What is the definition in C language? What is the meaning of the statement? What is the difference between them ?, Meaning difference

In the C language, we may be very familiar with definitions and declarations, but we may not really understand them!

Definition meaning: the so-called definition is to create (compiler) an object, allocate a memory space for this object and name it, that is, the variable name or object name we usually call, once the name matches the memory space, the name of the created variable cannot be changed in the lifecycle of the defined object or variable, 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: The statement has two meanings:

The first meaning: Tell the compiler that the name has already matched a piece of memory space, and the variable or object used by the subsequent code is defined elsewhere.

Eg: extern int I:

The second meaning: Tell the compiler that this name has been reserved. For example, the most familiar function declaration: void fun (int I, char c); at the very beginning, it means to tell the compiler, this name has been reserved. Other variables or objects in the code can no longer use this name, and the declaration can be repeated multiple times.

 

Major differences between definitions and declarations:

Defines the creation of an object and the allocation of memory space, and declares that no memory space is allocated.

------- Summary from deep analysis of C Language

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.