Importing C header files of language

First, for many adorable new programmers, fame and all the functions defined, all placed in a cpp file is more common. The import header files, it can be the difference between the body and the other functions it calls a function, make the program more standardized. Now I will say something about the use of header files, as well as some of the attention point.
1. simple application header file:
First, we create a simple C language function, and write our own import header file. The following is the header file and save way:
Here Insert Picture Description
The above is our first document, which needs to include the import library functions, macros and function declarations and definitions we have defined. When you save the file header, need to change the file type Header files, as shown below:
Here Insert Picture Description
Next, we introduced is operated, each function has a main function, which is the entrance of our program. So we have to create a cpp file, import the header file we just created. The following operation is the import header file:
Here Insert Picture Description
here there is a very problematic place, in use include the import header file, using the presence of <> and distinction for "". We use the best, "" guaranteed to be imported. The difference is as follows:
<> go find a header file system directory, without looking in the current directory. Like the standard header file stdio.h and stdlib.h this and other commonly used methods. The "" first looks in the current directory, if not, then the system directory to find. This used to include self-defined header files, the system uses the current priorities defined in the directory.
Then we just run the code:
Here Insert Picture Description
this is a simple header files imported. This is also a relatively simple import for large-scale works need to be defined for many functions, create headers can avoid a lot of duplication of work, and header files can be used to share, easy to transplant code and refer to the study.
The above is a simple C language header files. This is the first article I published in csdn, there is a bad place to write, please correct me, thank you.

Published an original article · won praise 2 · views 34

Guess you like

Origin blog.csdn.net/weixin_44029601/article/details/104873683