1: indicates that the compiler contains all information in the stdio. h file.
2. parentheses indicate that main () is a function name. int indicates that the function returns an integer. void indicates that the function does not accept any parameters.
3. Start of the function body.
4. Statement.
5. Value assignment statement.
6. Call the function statement and move the cursor to the beginning of the next line.
7. Use printf () to embed the num value into the quotation marks.
8. Return Statement.
9. The function ends.
2.2 instance description
I. # icnlude instructions and header files
# Include <stdio. h> is equivalent to entering the complete content of stdio. h In the file where the row is located. In fact, it is an operation that facilitates sharing public information among multiple programs.
# The include statement is a pre-processing instruction of C. : Prepare the source code before compilation. # The symbol indicates that this line is a statement processed by the C Preprocessor before the compiler takes over.
In the C world, people name the information set at the top of the file as the header. The actual code of the function is not in the header file, but in the library function. The header file guides the compiler to correctly combine your programs.
Ii. main () function
A c program is always executed from a function called main. () Indicates that main () is a function ,. Parentheses include information passed to the function.
3. Notes
Program comments are included between/**/. One advantage of C language comments is that they can be placed anywhere. A long comment can even be divided into multiple lines.
A New Annotation writing method. // This annotation must be limited to one line.
4. curly braces, program bodies and code blocks
Curly brackets define the boundaries of functions.
V. Statement
The declaration statement specifies a name for the variable and specifies the Data Type stored in the variable.
A semicolon is a part of a statement, not a delimiter between two sentences. Keywords are words used to express language. You cannot use them for other purposes. In C, all variables must be defined before use.
The OS and C libraries usually start with one or two underscores, so avoid such naming.
C language names are case sensitive.
Four benefits of declaring Variables
The order of statement assignments is from right to left, and the statement is also ended with a semicolon.
\ N is an escape character ,.
% D is a placeholder that indicates the position of the output num value. % Tells the program to output at this position, and d tells the program to output a decimal integer variable.
2.3 structure of a simple program
A program consists of one or more functions, including the main () function. The description of a function consists of the function header and function body. The function header includes the pre-processing statement and function name. The function header includes the pre-processing statement and function name. The function body is in curly brackets and consists of a series of statements. Each statement ends with a semicolon.
2.4 skills for making programs readable
Select meaningful variable names and comments, and use empty rows to separate multiple conceptual parts of a function.
More than 2.5 Functions
# Include <stdio. h>
Void butler (void );
Int main (void)
{
Butler ();
Return 0;
}
Void butler (void)
{
Printf ("You rang, sir? \ N ");
}
The first time a butler () function appears in the prototype, the C90 standard adds a prototype. The prototype is declared to tell the compiler that you are using a special function. It also specifies the function attributes.
The execution time of the butler () function is determined by the location where the main () function calls it, rather than the location defined in the file.
2.6 debugging
A common problem with the compiler is that the location of the error found lags behind a row than the real error.
2.7 keywords and reserved identifiers
A keyword is a word in C language and cannot be used as an identifier. Otherwise, it may be used as a syntax error.