I. Development Process of advanced language programs
1. analyze the problem and create a model
2. Presentation Model
3. Edit the source program
4. Program compilation (or translation) and link
The program written in advanced languages is called the source program, and the program that the machine can recognize and execute is called the executable program.
(1). Step 1
During the program editing process, the entered source file contains some verification codes.
But the machine can directly process 0 and 1 information. To solve this problem, you must first translate the source program file into information represented by code 0 and code 1, and save the corresponding file. This type of file that saves code 0 and 1 is called the target program file. The process of translating a source program into a target program is called compilation. During compilation, check the syntax and logical structure of the source program. Compile tasks are completed by software called compilers. The target program files cannot be executed. They are only some target program modules.
(2) Step 2
Link the target program module and the system inherent target program module (such as the module that executes input and output operations) required by the program into a completed program. The file generated by the correct link is the executable file. The software that completes the link process is called the linker.
5. program testing and debugging
6. Compile the program documentation
7. Program Maintenance
2. Some operating systems (such as UNIX) require that an integer be returned to the system after a program is executed. If the program runs normally or ends, 0 is returned, otherwise, a non-zero value is returned. Therefore, you must specify the main function as an int, and add the return statement return 0 at the end of the function body. Its function is to return 0 to the caller (operating system, indicates that the main function ends normally (that is, the program ends normally ). This statement must be written in the last row of the function body to make sense, because as long as this statement is executed, it indicates that the program ends normally and returns a 0 to the operating system.
Some operating systems (such as DOS and WINDOWS) do not require a program to return an integer. Therefore, you can leave the main function as an integer.
Of course, we 'd better use it for better program fault tolerance.
Int main (void)
{
......
Return 0;
}
3. There are many types of operators in the C language. To use these operators correctly, pay attention to the following three points.
1. Meaning
Note that the meaning of an operator symbol in a C language program is different from that in a common mathematical expression, for example, "= ".
2. Priority
The sequence of operations when multiple operators exist in an expression.
3. associativity
That is, if an expression contains multiple operators with the same priority, which operator is the first operation.
Iv. Identifiers and keywords
Identifiers are also called names, such as variable names, function names, and file names. In C language programs, the identifiers used must comply with the following lexical rules.
(1). the identifier is a sequence consisting of uppercase/lowercase letters, numbers, and underscores, but cannot begin with a number.
(2) c language distinguishes uppercase/lowercase letters from lowercase letters. For example, abc and abC are different identifiers.
(3) C89 requires the compiler to recognize a maximum of 31 valid characters. C99 requires that the compiler recognize no more than 63 valid characters.
(4) Ordinary identifiers cannot use names that have special meanings for the system, such as type names and statement names. These special names for the system are called keywords.
5. Develop good naming habits for Identifiers
(1) Try to be "knowledgeable" to increase the readability of the program.
(2) avoid confusing characters, such as 0 (numbers)-O (uppercase letters)-o (lowercase letters.
(3) The name should not be too short. Generally, the function name should use a dynamic object structure, such as PrintCalendar and IsPrime.
(4) Some Windows programmers also use the Hungarian naming method.
Vi. Statements
Prior to promulgation of C99, declarations of variables and functions were not used as statements (although they ended with semicolons ), they must appear before the C language (the declaration position must be concentrated before the statement ). C99 has changed this practice. It draws on the C ++ practice and does not have to concentrate on the execution of statements and can appear in any row of the program. In this way, the C language statements can be divided into execution statements and non-execution statements. Declarations are non-execution statements, and expression statements and flow control statements are execution statements.
7. "=" is not an equal sign, but a value assignment operator (it cannot be an equal sign ). The assignment operator has the combination of "right-to-left", for example, a = B = c = 5 + 3;
Excerpted from a stray calf