[Study Notes] the inclusion of the [C Language] file and the C language of study notes

Source: Internet
Author: User

[Study Notes] the inclusion of the [C Language] file and the C language of study notes

I. Basic Concepts

# Include, which can copy all the content of one file to another.

II. General Form

1. 1st forms # include <File Name>
Go to the directory where the function header file of the C language library is located to find the file.
 
2. 2nd forms # include "file name"
The system first searches for the source code in the current directory. If the source code cannot be found, it searches for the path in the path of the operating system before searching in the directory where the function header file of the C language library is located.

Iii. Usage notes

# The include command allows nested inclusion, such as. h contains B. h, B. h contains c. h, but recursive inclusion is not allowed, such as. h contains B. h, B. h contains. h.

Iv. Code

1.

. H file

1 #ifndef LISI_H2 #define LISI_H3 4 int sum(int a, int b);5 6 7 #endif

. C file

int sum(int a, int b){    return a + b;}

2.

. H file

1 #ifndef WANGWU_H2 #define WANGWU_H3 int minus(int a, int b);4 #endif

. C file

1/* 2 1. <> indicates the built-in file, and "" indicates the custom file 3 2. loop inclusion is not allowed, such as. h contains B. h, B. h also contains. h 4 */5 6 # include "lisi. h "7 # include" wangwu. h "8 9 # include <stdio. h> 10 11 int main () 12 {13 int c = sum (10, 19); 14 15 printf ("c is % d \ n", c ); 16 17 return 0; 18}

 

 

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.