Home>Article> How to learn c language

How to learn c language

angryTom
angryTom Original
2019-08-15 09:55:03 20220browse

How to learn c language

Original title: Written for beginners of C language, teaching you how to learn C language

Written for beginners of C language If so, teach you how to learn C language

How to learn c language

Don’t be impatient when learning C language, but do it step by step. You must know that haste makes waste. Don't blindly write a lot of code. Doing so will only pile up a lot of low-level code and make you form bad coding habits. First buy this basic textbook and take a look at it so that you can have a preliminary understanding of the C language.

Recommended tutorial:C language video tutorial

If you have high-level people around you If you are a developer, then there is nothing better than asking others for advice. But as far as I know, most beginners did not receive the guidance of a senior software engineer after entering the IT industry. Instead, they were pushed to the front line after joining the company to defraud customers for their bosses. In the process, many people are struggling to pile up code and earn pitiful wages. Although I was still making poor money, I was lucky because in my first company I met the mentor who led me to the field of Unix and C language. It was his sentence "Unix and C language". "Language is a technology that you have to learn throughout your life" made me fall in love with them. It was his sentence "You have a root password, it is not as simple as you having a root password, it is more of a responsibility" (said The premise of this sentence is that I deleted other people's things after entering the SUN server with the root password, because I thought these were useless things), which gave me a very specific understanding of the word responsibility. So here I ask the readers to allow me to use some space to express my deep gratitude to my neusoft mentor yuhj. At the same time, I would also like to express my deep gratitude to my friends at CU. It can be said that you are my second mentor and I can no longer live without you.

I hope everyone is luckier than me. Friends who are not favored by the God of Luck, don’t be discouraged. Come to CU to communicate and discuss with everyone, but be careful not to ask for details when discussing on the forum. Many things cannot be explained clearly in one sentence. Others can only give you a guide. No matter how specific it is, you can only rely on your own research and pondering. Go to the essence area in your spare time and you will gain unexpected benefits.

Don’t get confused when you see English. Although I am like this too, it’s not that I can’t understand it (after all, I have received CET4 and CET6 mute English education, so I can still understand it). Man's help is the best teaching material, and many foreign forums have very clear and simple descriptions of technology. More importantly, you will see things there that you cannot see in domestic forums (computer Technology has always been passed from the West to the East. I hope that one day foreigners will come to our Chinese forum to look for technical information).

How to learn c language

There is one thing that must be learned when learning C language, and it is best to learn it at the same time. Some friends may have guessed it, yes, it is Unix. It can be said that Unix and C language have been mentioned a lot. Wherever there is Unix, there is C language. At the same time, it is precisely because of C language that Unix exists (let us first discuss the philosophical issue of chicken or egg) Come on, hit me with a tomato), some people even say that C language is designed for Unix, which shows the unusual relationship between Unix and C language. Learning Unix is much easier now. In the past, Unix was run on large servers, but now with Linux (according to GNU, Linux is Linux and cannot be called Unix). You can install a set of Linux on your PC. When learning, be careful not to compare Linux and Windows when learning Linux. They are not the same. Linux will let you know what a classic is and will always let you show your ambitions in one direction. Windows will only let you play in other people's traps, and you have to change the trap from time to time. Listed below are some of my experiences in learning Unix:

1)To learn Unix and C language, I first recommend a book"Unix Advanced Environment Programming". This book is a classic for learning Unix and C. Try to write a practice program for all the system calls mentioned in the book, and first gain a perceptual understanding of what the system calls provided to users by the Linux system are for and how to use them. System calls are functions provided by the kernel to users to apply for kernel services. For learning the Linux kernel, starting with system calls is a good way. For the learning process, you can refer to the Linux online help and information on the Internet. When you feel that it is almost done, let me give you a contact question: to implement the functions of an ftp server and client, you can completely define some application layer protocols yourself, as long as you can transfer files with simple commands.

This question allows you to practice the basic programming methods of TCP/IP and the basic methods of file operations, which will be helpful for learning the kernel file system later.

2)When you have some understanding of the Unix system, at the same time, for most system calls (the key is the system calls about files, for the kernel of the Linux system, from the file It is relatively easy to get started with the system) and you have a clear understanding of it, I will recommend you a book"Linux Kernel Scenario Analysis". This book is a classic about the Linux kernel. The only flaw is that it does not have any information about the network subsystem. Detailed introduction to the system. You can start with the system calls of the file system, and slowly you will have a deeper understanding of Linux. At the same time, pay attention to the application of many classic methods and ideas in Linux. You will realize why Unix treats everything as a file, and everything you operate is a file operation, and you will slowly appreciate the classics of Unix.

3)After you have some understanding of the Linux kernel, you can find a direction to develop specifically. If you want to be interested in the currently popular network programming, then I recommend you a book"Detailed Explanation of TCP/IP". This book is a classic about the TCP/IP protocol. You will learn how the TCP/IP protocol stack is implemented, why, and how the protocols at each layer work. After you finish reading this book, you can write a DOS attack program and sniffer yourself.

I put it simply. In fact, every book I mentioned is enough for you to study for a long time at least, so I hope beginners don’t be anxious and not arrogant. I believe that as long as you work hard, you will definitely become a master. .

When writing code, everyone should pay attention to developing good coding habits, style and abstraction ability.

The following is a 20-word guideline for everyone when writing code:

1) Functions should be small

Try to make the function as general as possible, with fewer lines of code. A function only completes a simple function. You can see at a glance whether there are code errors in this function. Each function is robust, then you The program is robust.

2) There should be less code

When completing a function, the less code the better if the logic is clear. Never compare who wrote more code. .

3) The algorithm should be better

When completing a function, efficiency must be considered. Currently, computers have a large amount of memory, so memory is no longer the primary consideration. However, Efficiency is still important in some special places. If you have a high-efficiency algorithm, you don’t need an inefficient algorithm. Take a look at this article. There is an excellent post about removing the spaces on both sides of a character (trim). Many people have proposed algorithms, but one algorithm is The best, the most efficient, the least code, is the best reflection of a good algorithm

4) The naming must be clear

The naming must be clear, and the most important thing is to use Chinese Predicate structure such as set_buffsize()

5) There should be more files

Try to divide a large program into multiple files, and try not to exceed 1000 for one file OK, so you can clearly know which file code is robust and which file may have hidden dangers. When checking the code, you can check certain files in a targeted manner

The above is the detailed content of How to learn c language. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn