Write to C language beginners

xiaoxiao2021-03-06  64

Write to C language beginners

--www.chinaunix.net (LDAP)

A few days ago I wrote a "UNIX C language worth paying attention" a post, talking about learning the high-quality code in the open source software in foreign countries, but there is a friend to talk about the process of reading the code. It feels very difficult in it, thinking about it is true, however, if there is no one, if there is no one, it is very difficult to find the entry point, so I have written this article hoping to help the v-language enthusiasts. There are a lot of lyrical places in the article, please forgive, because this article made me think of it when I first graduated, so I was a little emotion. At the same time, there are some personal prejudices in the article, and I hope that people who have the opposition opinion will bear with me, since it is a prejudice, it is just a prejudice.

Learning C language should not be anxious, to be gradually entered, and you must not reach the reason. Don't write a lot of code blindly, so you will only pile a lot of low-grade code, and you will make you a bad code habit. First buy this basic textbook to see, make a preliminary understanding of the C language, in fact, I still put "The C Programming Language" and "C Programming (Second Edition)" (university textbook). Sometimes I will go through the concept of basic concepts.

If you have a high level of developers around you, then it is better, and you will ask others. However, in the case of my understanding, most of the beginners did not get a senior software engineer's guidance after entering the IT industry, and it was pushed to the front line after I was in the Division. Many people in this process are in a bitter bile code, earning poor salary. Although I also took poor money, I was lucky, because I met the mentor leading me to UNIX and C language in my first company, is his sentence "UNIX and C The language is that you have to learn from your life. "Let me feel fatched with them. It is his sentence." You have root passwords, not you have a root password so simple, more is a responsibility "(said The premise of this sentence is that I use the root password to enter the Sun server and delete someone else, because I think these are useless things) make me a very specific understanding of the words of the responsibility. So here, please, readers, allow me to express my deep gratitude to my Neusoft's mentor Yuhj. At the same time, I also express my deep gratitude to the friends of CU. It can be said that you are my second tutor, I can't leave you.

I hope everyone is lucky than I am, don't get lucky friends, don't be discouraged, and I will communicate with you, discuss it, but pay attention to it, don't put the roots when I discuss it, many things are not a sentence It is clear that others can only give you a guide, and then only rely on their own research, ponder. Go to the essence to see if you are free time, you will have an unexpected harvest.

Don't see English, even though I am like this, I don't understand (after all, I have received the education of CET4, 6-class dumb English, or can be understood). Man's help is the best textbook and many foreign forums are very clear and very simple. More importantly, you will see something you can't see in the domestic forum (computer) The technology has always been passed by the West to the East, I hope to come to our Chinese forum to find technical information on the foreigners.

Learning C language is also a thing to learn, and it is best to learn at the same time, some friends may have guess, yes, unix. Unix and C language can be said that everyone has mentioned, there is a C language in Unix, and it is also a C language, which has UNIX (we still discuss the philosophical problem of the eggs or egg growth Let's take me tomatoes.) Learning UNIX is now much easier, before UNIX is running on a large server, but now there is Linux (Meaning according to GNU, Linux is Linux can't call UNIX), you can put a set of Linux in your own PC. Learning, pay attention to learning Linux Don't take Linux and Windows to compare, they cannot be sympathy. Linux will let you know what is classic, always makes you a big exhibition in one direction, Windows will only let you play a big knife in someone else's suit, and you will change a set of juggles from time to time. Here, some of the experience I am learning UNIX: 1. Learn the Unix and C language, first recommend a book "UNIX Advanced Environment Program", this book is the classic of UNIX and C, try to take the book The system calls mentioned in the middle have written an exercise program. The sense of sensibility knows what is done by the system call to the user. How to use it. The system call is the function of the kernel to provide the user to apply for kernel service. For the LINUX kernel learning, it is a good way to start from the system call. The learning process can be found in Linux online help, and information on the network. When you feel almost, then I will give you a contact title: implement a FTP server and client function, you can define some of the application layer protocols, as long as you can transfer files with a simple command.

This topic allows you to exercise the basic programming method of TCP / IP and the basic method of file operations will be helpful for file systems for later learning kernels.

2, when you have some understanding of the UNIX system, at the same time, for most system calls (the key is about file system calls, there is also a clear understanding of the LINUX system. I recommend you a book "Linux Kernel Scenario Analysis", which is the only beauty of the Linux kernel's classic. There is no detailed introduction to the network subsystem. You can start from the system of the file system, slowly, you will have a more in-depth understanding of Linux. At the same time, pay attention to many classic methods and ideas in Linux. You will realize why Unix looks all things as a file, and what is done to file, you will slowly understand the classic of Unix.

3. When you have some understanding of Linux, you can find a direction to develop, if you want to be interested in popular network programming, then you will then recommend a book "TCP / IP Detailed explanation" This book is the classic of TCP / IP protocol. You will learn that the TCP / IP protocol stack is if implemented, why, how to work between the various stations. After you read this book, you can write a DOS attack program and Sniffer yourself.

I said, in fact, every book I mentioned is at least for a long time, so I hope that beginners don't worry, I believe that as long as I work, I will be a master.

When you write the code, you should pay attention to developing good code habits and styles and abstract capabilities.

Let's give everyone 20-word policy when writing code:

Small function

Try to get the universal point of the function, the code line, one function completes only a simple feature, you can see that this function does not have code errors, each function is strong, then your procedure is robust. . When the code is less than a function, the less code is, the less the code is, don't write more than the code.

The algorithm should be good to consider efficiency when completing a function. At present, the computer's memory is large, so memory is not the primary consideration, but it is still important in certain special local efficiency. If an efficient algorithm does not have a low efficiency algorithm, you can see a post on the post (TRIM) of the space on both sides, many people put forward algorithms, but there is an algorithm is The best, the highest efficiency, the least code, is the best embodiment of the algorithm.

Naming to be clear, you want to know, the best use of the predicate structure in Chinese, such as set_buffsize ()

Document should try to divide a large program security into multiple files. One file should not be more than 1000 lines, so it is clear that the file code is robust, that file may have a hidden danger, when the code check Can have targeted checking a few files

转载请注明原文地址:https://www.9cbs.com/read-88548.html

New Post(0)