Talk C Chestnut Bar (11th: C Language Example-file organization structure)

Source: Internet
Author: User


Crossing, everyone, from today onwards, we talk about the large-scale couplet science fiction: C Chestnut, that is, C language examples. Gossip Hugh,

Words return to the positive turn. Let's talk C chestnuts together!


Crossing, the last time we were talking about the example of least common multiple, this time we don't say a specific example, let's talk about the file in the C example

Organization method and the "File organization method" When actually developing the software.


Crossing, in the example I wrote earlier, there is only one source file (that is, the. c file that you usually see). I did not write the header file individually (also

is usually seen in the. h file), but the contents of the head file are placed in the source file. Primarily, the contents of the header files in these examples are not

More if a header file is written separately. A bit superfluous, so the contents of the head file and the source file are put together. In the actual software open

In the hair, the contents of the header file need to be written separately from the contents of the source file, so that the file can be managed well. Imagine that the actual software is open

In the process, it will not be like the example I wrote here, only dozens of lines of code, a file can be done. In the actual software development, there will be

Thousands of lines of code, there are hundreds of files, so many files together, if there is no good management method, then will give the soft

Development, so the actual software development requires the head file and the source file to write separately.


Header files typically contain file references, macro definitions, global variables, structs, enumeration declarations, function declarations. The source file typically contains functions

Implementation, the main logic of the program. This is a common approach to file organization and structure.


In the C example I wrote, if there is less content in the header file, I will not write a header file specifically, but put all the content in the source file

In This does not conform to the file organization structure method, but it is more convenient and practical. If the contents of the header file are more, then I will

Write a header file alone, and write the contents of the head file separately from the content in the source file. This is done to facilitate the management of documents and

The method used to organize the structure of the file.


Everyone, crossing, we're going to talk about the structure of the document. I want to know what the following example, and listen to tell.

Talk C Chestnut Bar (11th: C Language Example-file organization structure)

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.