The advantages and disadvantages of C language
Advantages: 1. Design features: A language that incorporates control features designed to enable users to use top-down planning, structured programming, and modular design;
2. Efficiency: C programs are often very compact and fast running;
3. Portability: If the modifications are necessary, it is usually only possible to change the contents of a header file accompanying the main program;
4. Strong and flexible;
5. For programmers ' needs.
Cons: The introduction of C, combined with its rich operators, makes it possible to write code for distress comprehension, (C language has an annual "Vague Code" contest);
Ii. 7 steps to using C language
Step 1. Define the program objectives;
Step 2. Design program, the first two steps do not need to consider the specific code details, but seriously consider the whole program planning and structure;
Step 3. Write code, according to the previously designed program framework for code writing, in code writing should pay attention to adding text annotations;
Step 4. Compile: The first thing to understand is that the compiler is also a program whose job is to convert the source code into executable code. The executable code uses the computer's native language or machine language representation of the Code, which consists of detailed instructions in a numeric code. The final result is an executable file that contains code that the computer can understand and can run;
Step 5. Run the program;
Step 6. Testing and commissioning procedures;
Step 7. Maintenance and modification procedures: These tasks are simplified if the program is clearly written and used in good design practice.
"Advice" develop the habit of planning before writing code;
Third, the programming mechanism
The basic strategy of 1.C programming is to use the program to convert source code files into executable files; C in two steps to complete this work, compile and link.
The compiler translates the source code into intermediate code, and the linker combines the intermediate code with other code to generate the executable file.
Approximate process: The executable code, the target code, the source code, the compiler, and the target code, along with the library code and the startup code.
Although the target code file includes the machine language code, the file cannot be run, and the first missing element is the startup code. The startup code is equivalent to the interface between the program and the operating system.
The second element that is missing is the library code. The target code contains only the instructions that declare the use of the function, and the actual code is stored in the library file.
The purpose of the linker is to combine the target code, the startup code, the library code, and the existence of a single file, which is executable code.
Iv. Language Standards
1. The first ansi/iso C standard: C89 or C90;
2.C99 Standard: The standard before the revision.
Five, after-school exercises
1. What does portability mean in terms of programming?
Portability is good, meaning that code can be compiled and run on other systems with little or no change;
2. Explain the difference between the source code file, the target code file, and the executable file?
Source code file: Contains code files written by programmers in any programming language;
Target code file: Contains the machine language code that the source code translates into;
Executable files: Machine language code, library routines, and machine code for startup code;
3.7 Steps of programming?
1. Define program objectives, 2. Design procedures, 3. Write code, 4. Compile, 5. Run the program; 6. Commissioning and testing; 7. Maintenance and modification;
4. What is the compiler's task?
The task of the compiler is to convert the source code files into executable code files;
5. What is the linker's task?
The linker's task is to combine the target code, startup code, and library routines to generate executable code files.
6. Programming Exercises:
1. Program target: Prompts the user to enter the inch value, then converts the inch value to the centimeter, then outputs the input value and the conversion value simultaneously;
2. Design program: Enter the value of inch, determine whether the input value conforms to the inch value condition, if the match, then converts to the centimeter value output, if does not conform, prompts the user to enter the error and re-enter.
"C Primer Plus notes" chapter I