C language entry reference (3), C language entry reference
3. hello, world!
Hello, world! Hello, world represents the beginning of everything. Programmers inject life and soul into the program. Every programmer should believe that code is live and has a life and soul. We bring the soul and life to code, "Programmer (APE)". Hello, world! The popularity of this classic program is attributed to The book The C Programme Language (C programming Language). The first program of many programmers is hello, world !. Programming is generally divided into seven steps (here the concept is referenced in the book C primer plus. This book is also one of the classic C language entry books, interested readers can buy to study)
1. Define program objectives
Programming is used to solve the problem. before writing a program, we should be clear about what this program is. Do not program without any aim.
2. Design Procedures
With the problem to be solved, we are now thinking about how to use a program to solve the problem, and how the program is implemented, target groups, console programs, or GUI (graphical user interface) program.
3. write code
After the program is designed, We need to write code to implement it. We write code in the text editor, create the source code file (the extension of the C language source code file is. C), and attach the source code of the C language hello, world Program:
1 #include<stdio.h>2 int main()3 4 {5 printf(“hello,world!\n”);6 7 return 0;8 9 }
4. Compile
As mentioned above, a computer requires a translator called "compiler" to translate (compile) the C language into binary code that the computer can understand and recognize. After compiling the code, A. EXE (Executable File) file will be generated after compilation. In the process of compilation, not only does the compiler work, but it completes the translation and the compilation. It is done by a tool called "linker. After the compiler compiles the source code, the linker generates a target file with the extension. obj. The target file cannot be directly executed. The target file can be directly executed only after the Link Library and the startup code generate the. exe executable file. The compiler can also check whether the code written by the programmer is incorrect if the compiler discovers an error. It stops compilation and reports an error.
5. Run the program
In Windows, double-click the. exe file (Executable File) generated after compilation and execution to directly execute the file.
6. Test and debug the program
After the program is written, we should run it. Check whether there are any errors like what we designed at the beginning. (This step is called a test ). If an error occurs during the running of the program, we should find and fix the error (this step is called debugging ).
7. Maintain and modify Codes
After creating a program, it does not mean that the work is over. If we want to add some new functions to the program, we need to modify the code. When users use your program, they may find some errors that you and the compiler have not found. At this time, programmers need to modify the code and optimize the program. A good programmer can not only write code, but also write comments. The code written by excellent programmers is elegant, neat, and elegant. During the development process, we should also pay attention to the details, such as whether the code is clean, whether there are write comments, and whether the variable name is meaningful. After all, the code is written to people.
Readers who have read this tutorial may wonder if you are still afraid of programming and are still confused? Programming is not as difficult as you think. As long as you are willing to work hard, you will certainly learn. Some readers may not be very good at English and mathematics? Don't be afraid. The previous study is not closely related to English mathematics. It is enough to be rough. However, this does not mean that you do not need to learn English or mathematics. Good programmers are not inferior in English and mathematics. In the future development process, we need to read a lot of English documents and documents. Some software is also in English, which tests our English proficiency. Programmers talk about life-long learning and life-long learning. The previous study may be boring, a little difficult. I sincerely hope that you can pass those thresholds.
If any error occurs in the text, please correct it. It cannot be reproduced without the support of the blogger (not to be continued ......)