Step 1: Define Plan Objectives
Before you start writing a program, you should know clearly what you want the program to do. Consider the information the program needs, the calculations and operations the program needs to perform, and the information the program should report to you. At this planning stage, you should consider the problem with general concepts rather than some specific computer language terms. Simply put, what we have to think about is what this program is used for.
Step 2: Design the program
When you have a conceptual understanding of what the program needs to complete, you have to decide how the program should be completed, what the user interface should be, how the program should be organized, who the target users are, how long it will take you to complete the program, and so on.
In fact, this part is just like writing a composition. After you decide what topic you want to write, you should list the outline of your article, how many paragraphs you need, what skills you need, what to write in each paragraph, and how much time you have to finish this article. Just plan out these contents and make an outline, and then implement them in turn.
Step 3: Write the code
After the program has a clear design, it can be realized by writing code. In other words, turn your design ideas into C language. This is where you really need to use C knowledge. You can write your ideas on paper, but in the end you have to input the code into the computer. Generally speaking, you need to use a text editor to create a file called source code, which contains the C implementation of your program design.
Step 4: Compile
The next step is to compile the source code. However, the compilation details depend on the programming environment, and we will soon see some common environments, so let's get a general idea of what to do first.
As mentioned earlier, a compiler is a program whose job is to convert source code into executable code. An executable code is a code expressed in the machine language of a computer. This language consists of detailed instructions expressed by digital codes. C compiler is used to convert C language into machine language. The C compiler also adds code to the final program from the C library. The library includes many standard routines for you to use, such as printf) and scanf (). The end result is an executable file that contains code that the computer can understand and that you can run.
Step 5: Run the program.
Generally speaking, an executable file is a file that can be run directly after being opened. In general operating system (such as WindowsLinux), if you want to run a program, you just need to double-click the file or right-click to open it. This is an executable file. So how do I generate an executable file? For example, in order to run a program with QT compiler in Windows environment, you can use the shortcut key Ctrl+R to generate the program and display the program structure, while if you use Visual Studio compiler, you can use Ctrl+F5 to compile and run it.
Step 6: Test and debug the program
It is excellent that the program can run normally, but sometimes it may not run correctly. Therefore, you should check whether there are any errors in the program. This error is called a Bug in computer jargon. Debugging is to find and correct program errors. You will naturally make mistakes when you study, and it seems that you will make mistakes when you program, so when you apply what you have learned to programming, you'd better be prepared to think that you are prone to mistakes at any time. When you become a more skilled and skilled programmer, your mistakes will become more serious and more difficult to detect.
Step 7: Maintain and modify the program
After creating a program for yourself or others, the program may have a wider application. If so, you may find that changes are needed, that is, maintenance and modification of the project. I have to mention the code style and the role of comments here. Many people don't like to write comments, and the code style is extremely messy. But if you maintain someone else's program, if he doesn't write comments and the code piles up together, you may have a terrible headache and just want to scold the programmer who wrote this program. It is a very good habit for people and themselves to develop a good programming style and mark notes after writing the program.