Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the command keywords contained in the file in C language?

Shulou Source: shulou.com Published: 2022-06-01 01:36:49 09月21日 Update

This article mainly explains "what are the command keywords contained in C language files". Interested friends may wish to have a look at them. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the command keywords contained in C language files?"

The keyword of the file that contains the command is "include". The file containing command "# include" is a common preprocessing command used by C language programs to introduce the corresponding header file (".h" file) in the format of "# include" Header.h "".

The operating environment of this tutorial: windows7 system, C99 version, Dell G3 computer.

# include is called the file include command, which is used to introduce the corresponding header file (.h file). # include is also a kind of C language preprocessing command.

The process of # include is simple: insert the contents of the header file into the location where the command is located, thus connecting the header file and the current source file into a source file, which is the same as copying and pasting.

# include can be used in two ways, as follows:

# include # include "myHeader.h"

Use angle brackets

< >

The difference from the double quotation mark "" is that the search path for the header file is different:

Use angle brackets

< >

The compiler will look for the header file under the system path

Using double quotation marks, the compiler first looks for the header file in the current directory, and if not, it looks under the system path.

In other words, using double quotes has one more lookup path than using angle brackets, and it is more powerful.

Previously, we have been using angle brackets to introduce standard header files, but now we can also use double quotes, as shown below:

# include "stdio.h" # include "stdlib.h"

Stdio.h and stdlib.h are standard header files, they are stored in the system path, so the use of angle brackets and double quotation marks can be successfully introduced; and our own header files, generally stored in the path of the current project, so can not use angle brackets, can only use double quotation marks.

Of course, you can also add the directory where the current project is located to the system path so that you can use angle brackets, but generally no one does so, which is purely unnecessary and thankless.

Notes on the usage of # include:

A # include command can contain only one header file, and multiple header files require multiple # include commands.

The same header file can be introduced multiple times, and the effect of multiple introduction is the same as that of one introduction, because the header file has a mechanism to prevent repeated introduction at the code level.

File inclusions allow nesting, that is, one included file can contain another file.

Example:

The code contained in my.c:

/ / calculate the sum from m to n and int sum (int m, int n) {int I, sum = 0; for (I = m; I

Tags: File command angle bracket path quotation mark language system key keyword code package content effect same size that is multiple place standard Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS Linux Shulou Technology Shulou Information