1. #include <stdio.h>
- #include is one of the pre-processing directives for C, so-called preprocessing, which is done before the compilation, and the preprocessing directives are usually preceded by #
- #include instruction follows a file name, and after the preprocessor discovers #include instructions, it finds the file based on the filename and includes the contents of the file in the current file. The text in the included file replaces the #include instruction in the source file as if you had copied all the contents of the contained file to the location of the #include instruction.
- If the included file extension is named. h, which we call "header file", the header file can be used to declare a function ("function" is an object-oriented "method"), in order to use these functions, you must first use the #include directive contains the header file where the function
- The #include directive is not limited to. h header files, and can contain any code files that the compiler can recognize, including. C,.hpp,.cpp, and so on, even. Txt,.abc and so on .
In other words, you can put the code in lines 3rd through 9th into other files, and then include them with #include directives, such as:
1> put the code from line 3rd to line 9th into My.txt
2> include My.txt file in Main.c source file
The program can still be shipped as usual , because the #include function is to completely copy the file contents to the location of the #include instructions
- But you may wonder why stdio.h use angle brackets to <>, while my.txt use double quotes ""? This very good difference, if the result is the system comes with the file, preferably with <>; if it is a developer's own files created, it is best to use ""
Note: here with TXT file purely demo, usually do projects do not do this, unless eat full of support, will write the code into TXT
stdio.h
- Stdio.h is a header file in the C language library that defines some standard input and output functions. In the 1th line of code in MAIN.C, the # include directive contains the Stdio.h file.
- #include指令包含了stdio. h file , the stdio.h has a printf output function that can output data to a standard output device, such as a monitor screen.
2. Summarize the operation steps of the first C program:
1. Execute the # include directive before compiling, copy the contents of the stdio.h into the source program
2. Compile the source program, generate the target file
3. Link the C-language function library, generate the executable file
4. Run the executable file and output "Hello, world!" on the screen
"C language" some important points of knowledge