How to learn C language

Many people feel overwhelmed by learning C, and often ask me the same question: how exactly do I learn C? I'm a teacher who has been developing programs for many years, and like many people who are just starting out, the first computer language I learned was C. I've learned a lot about C, and I've learned a lot about how important it is for a programmer to learn it. After all these years of development, I y appreciate how important the C language is to a programmer. If you don't know C, you want to write the underlying program, which almost sounds ridiculous, and if you don't know C, you want to write a good and efficient program, which is just a pipe dream. Why is C so important? First:C syntax structure is very simple and subtle, and write programs that are efficient and easy to describe algorithms, most programmers are willing to use C to describe the algorithms themselves, so if you want to be good at programming, you have to learn it. Secondly, C allows you to get down to the bottom of the system. Which operating system do you know that is not written in C? All windows, Unix, Linux, Mac, os/2, there is no one inside and outside, if you do not understand the C language, how can you go deep into these operating systems? Not to mention you to write their kernel program. Third: many new languages are derived from C. C++,Java,C#,J#,perl... Which one is not? Mastering the C language, you can say that you have mastered a lot of languages, after a simple study, you can use these new languages to develop, this once again proved that the C language is an important foundation for program design. And ah, say a little more: even now the recruitment of programmers, the test is to test the C language, you want to join the it industry, then you must master the C language. So how exactly do you learn C language? 1: work to do a good job, must first benefit from its tools here to introduce a few essential to learn C language east east: a development environment, such as turbo C 2.0, which once occupied the DOS era development program half of the rivers and mountains. But now the windows era, with turbo C have the feeling that it is not aspect, edit the program up is very hard, and drag and drop, not to mention the function variable auto-sensing function, query reference material is not convenient. It is recommended to use Visual C++, this thing is relatively large, but once installed, it is very convenient to use. A learning tutorial, now C language textbooks as many as hair, but we recommend the use of "C Programming" Tan Haoqiang edited by the second edition of Tsinghua University Press, this book is very suitable for beginners, and the contents of the book is also very precise. In addition, there are now a lot of auxiliary learning software, after all, now is the Window era, learning software as much as a hair, unlike when we were learning, only reading and doing so old-fashioned. I recommend an "integrated learning environment (C language)", where the summary of knowledge points and examples are very good, there are question bank test environment, said to have thousands of questions, and even a windows trubo C, beginners do not even have to install other compilers, you can practice programming, very suitable for beginners. Very suitable for beginners. There is also a "C language learning system" software, but the feeling is just a question bank system, if you feel that not enough questions to do, you may also want to try. 2:What is the best way to learn a computer language? Answer: reading programs. That's right, reading programs is the fastest and best way to get started in learning C language. As I, now learning new J#,C# and other languages, no longer hold the book to chew line by line, but to learn their routines. Of course, for beginners who have not studied any computer language, it is better to read the tutorials first, and after studying each chapter, carefully experience all the concepts of the chapter, and then do not miss all the routines mentioned in the chapter, and then carefully study the program until every line is understood, and then look for a few programming topics, preferably similar or the same as the routines, and try to write this program by yourself that you have already read and understood. Do not think that you have read the routine, you can write and it is the same program, definitely not necessarily, do not believe that you try it, if you can not write, do not worry, go back and then continue to study the routine, think about why they can not write, and then go to write this program, over and over again, until you get your hands on it until, congratulations, you're almost beginner. 3: the highest level of writing programs is actually to master a variety of means of solving problems (data structures) and problem-solving methods (algorithms). Is not to write the bottom of the program is a master of programming? Not also, write the underlying program, is nothing more than a mastery of the structure of the hardware, and hardware and hardware is not the same, to write a driver for a chip, is nothing more than a master of the chip's various registers and their combinations, and then write the value of the value of the read value, that's all. This is just familiar with some io functions. So how do you become proficient in programming? How to be proficient in program design? For example: you have 10 people in front of you, to find a person called "Zhang San", what should you do? The first method: directly ask these 10 people: "Who is called Zhang San". The second method: you go one by one to ask "Are you Zhang San?", until the person you ask is Zhang San. Until the person you ask is Zhang San. The third method: You go from one person to another and ask them "Do you recognize Zhang San, show me". Do not underestimate the problem, you said that of course you will choose the first method, yes, congratulations on your answer, because this method is the fastest, the most efficient, but in the program design to find the optimal way to solve the problem and you use the means to test the level of a programmer's program design is an important symbol, and is not easy to achieve. Just now this problem is similar to the data structure and algorithm: Map data structure, exhaustive search and half-fold search. So master the data structure and some common algorithms, is the inevitable road to the top. Finally, we recommend Yan Yumin's "Data Structures" Tsinghua University Press, and hope that everyone who wants to become a programmer will read this book. [Edit: Zhao Jinjun] Second, the language learning method Talk about my learning method, throw a brick to attract jade! I'd like to talk about my learning method, just to throw some light on the situation. But if someone else learns it in a month, and you learn it in 100 years, then it's too late. (:) So, learning or to pay attention to the method. If you learn in the right way, you get twice the result with half the effort; if you don't learn in the right way, you get twice the result with half the effort. What is the shortcut to learn C language? My answer is to read books. What is written in the book is written by the previous decades of experience, read ten books, it is equivalent to draw on the previous decades of strength, then your internal strength will also rapidly rise 1 a.). (*) of course, the book should be a good book, only good books are rich in nutrients. If you spend 1 day to read a broken book, and the book introduces the knowledge although for you is new knowledge, but because the book is not organized properly, or not enough depth, so that you get very little nutrients, not as fast as their own research day to day, this kind of book is not worth looking at. What are the best books to read to learn C? I think the first thing to do is to read the basic books, such as the four books introduced in the "C language of the four books". (Although many of these books are out of print, I'm sure the electronic versions are beneficial as well. Besides, if you really want to read them, I'm sure there's a way for you to get them.) You'll read these books in a very short period of time (like a month or two), depending on your foundation and enlightenment. What about those books to read after that? I might as well list a few more: Bjarne Stroustrup's The C++ Programming Language (《C++Programming Language》)is a must-read, which defines some of the basic concepts of C more fully and carefully than any other C book I've ever seen; Bjarne Stroustrup's C++. The Design and Evolution of C++ by Bjarne Stroustrup and C Interfaces and Implaementations Techniques for Creating Reusable Software by David R. Hanson. (Reusable Software) by David R. Hanson are a must, these two books talk about how to use C to implement exception handling, implementation type encapsulation and extension, and other high-level techniques that are often used in big projects. Other books, operating systems, compilation principles, algorithms, and patterns. If you read a lot of books, you will be able to code like a god. All in all, just as the "biography" in the cloud: "born to know, also on; learning to know, also second; sleepy and learning and its second." We can't always learn because we are stuck, but we have to do it before the soldiers and horses move, food and fodder first. Reading books is the guide to learning, books can introduce clear concepts one by one, but the book can't introduce the details of the application to you one by one, because the application is always complicated and varied moves. Therefore, if we want to be familiar with the tricks and know how to use them, we should also read the source code, Linus often says Read the fucking source code when answering questions for others, and Hou Jie also mentions that "there is no secret before the source code." This is the aphorism of the masters. That's the master's aphorism. Source code is like an animation, like a slide show, which shows you the moves in the book one by one. It can be said that most of the experience of the masters comes from the code. Source code, like books, should be good, not bad. Here, I recommend looking at the Linux kernel source code and the Linux tcp/ip source code, both of which are open source and available at your fingertips. In addition, you can also with Andrew S. Tanenbaum's "Operating Systems: Design and Implementation" (Operating Systems: Design and Implementation), Mao Dezao Hu Ximing's "Linux kernel source code scenario analysis", Jonathan Corbet, Alessandro Rubini, Gregorio González's "Linux kernel source code scenario analysis", and the "Linux kernel source code scenario analysis", and the "Linux kernel source code scenario analysis". Alessandro Rubini, Greg Kroah-Hartman co-authored "Linux Device Driver" (Linux Device Driver, 3e), W. Richard Stevens "TCP / IP Illustracted (3)" (TCP / IP Illustrated ), W. Richard Stevens "Advanced UNIX Environment" (Operating Systems: Design and Implementation). Richard Stevens "Advanced Programming in the UNIX Environment" (Advanced Programming in the UNIX Environment, the new edition added Linux kernel content) and other books to see, convenient. Of course programs are not read, they are written. When I was in high school, I insisted on writing programs for 6 hours a day, and I repeated the exercises in Data Structures, Permutations and Combinations, and Graph Theory many times. By now, although there has been a lapse of five or six years, a lot of content has long been forgotten, but it has developed my strong coding ability and debugging ability, until now also has a great help to my work.