Current location - Quotes Website - Collection of slogans - C language foundation
C language foundation
Don't look at the basic course of C language. Learning C language can't be separated from the concrete system, and you can't help but understand the computer architecture, operating system principles and compilation principles. I recommend you to read this open source book:

One-stop learning of Linux C programming

If you are learning Windows, you can install cygwin to simulate the linux environment. Download address:

This is the introduction of this book. Sharpening a knife is not a mistake for a woodcutter. After reading it, you will fall in love with this book:

What are the characteristics of this book? Who are your target readers?

This book was originally one of the textbooks tailored by Beijing Asia Embedded Education Research Center for the employment class of embedded Linux system engineers. This course is a four-month full-time vocational training, which requires students to have a very solid C programming ability, be proficient in using Linux system, and have a deep understanding of computer architecture and instruction set, operating system principles and device drivers. However, the level of students when they enter school is very elementary and uneven: their academic qualifications range from junior college, undergraduate to graduate, their majors are all computer-related and very irrelevant (such as accounting), and their previous occupations are all technology-related and completely irrelevant (such as HR), ranging from their early twenties to their mid-thirties. So many people with completely different backgrounds, different foundations, different thinking habits and understanding abilities come to the same class, and everyone is eager to learn embedded development technology and join the IT industry. This is the characteristic of vocational education, and it is also the main problem that I need to consider when writing this book.

Learning programming is by no means a simple matter, especially for beginners with zero foundation. It takes four years to train a person from scratch for computer major in university, including calculus, line generation, randomness, discreteness, combination, automata, compilation principle, operating system, computer composition principle and a bunch of basic courses. Plus a bunch of specialized courses such as C/C++, Java, database, network, software engineering and computer graphics. Finally, cultivate a student who can find a job. Unfortunately, many schools have not done this last item well. Many students who come to the Asian Games for training have studied for four years, but according to our assessment, their foundation is almost zero. I don't know why. In sharp contrast, given only four months, we also need to start from scratch, and finally cultivate a student who can find a job and ensure that he can find a job. This is the characteristic of vocational education.

Why did I say "give us four months"? We want to teach for four years, but the length of class hours is not up to us, which is determined by market rules. It takes four months to complete a four-year task. How can we accomplish such an almost impossible task? The answer given by some vocational education is "pragmatism" and the slogan is "Learn if it is useful, but don't learn if it is useless". They wantonly belittle that the basic courses taught in universities are outdated and useless, and only the skills taught are practical. This guess is very bad. I think every course taught in the university is very useful, and the basic knowledge will never be out of date, but those fashionable "practical technologies" may soon be out of date.

How can a four-year task be completed in four months? Our answer is "optimization". The biggest drawback of the current university curriculum system is that it does not consider optimization at all. Anyone who has been there will feel this way. Freshmen and sophomores have learned a lot of math classes, but they don't know what they are for. Why should they learn them? If you don't even know what learning is for, how can you be interested in learning well? Then in my junior year and senior year, I used my previous knowledge to find out how useful the math I learned before was. However, I forgot all about it long ago and returned it to the teacher after the exam. Go back and learn it again. At this time, I discovered that many things I didn't understand before are now really understood. So the first two years were not wasted? Another shortcoming of the university curriculum system is the lack of flexibility. Each course must take up one semester and be taught by a teacher. There is no communication and cohesion between teachers in different courses. In fact, these courses are interdependent, and forced disassembly is not in line with the laws of human cognition. For example, when I first went to college, I was forced to learn C language in the first half of my freshman year. In fact, C language is a very difficult programming language. It is impossible to learn without understanding the compilation principle, operating system and computer architecture. That half semester was naturally wasted. At that time, almost all computer-related majors in schools were like this. Some schools are even crazier when they start to learn C language, and they start to learn C++, which leads most students to think that they know C language, but in fact they have only a little knowledge. When they actually write code, they often fall into a Bug, but they have no chance to learn C language systematically, because in the school's view, C language class was "finished" for you as early as freshman year, just like. Obviously, if we want to optimize these courses seriously, there is indeed a lot of water to squeeze.

This book has the following features:

*

C language is not isolated, but combined with compilation principle, operating system and computer architecture. In other words, the content of this book is only based on C language, and it really talks about the principles of computers and programs.

*

Emphasize basic concepts and principles, and attach great importance to the dependence between concepts in the order of arrangement. Every time a new concept is introduced, it only depends on the concept mentioned in the previous chapter, and it will never depend on the concept mentioned in the next chapter. In some places, in order to complete the narrative, they will also quote what will be said later, such as "We will explain the content about XX in Chapter XX". All these quotes are not necessary dependencies, so you can pretend it doesn't exist and continue reading.

*

Try to ensure that every knowledge point is used before introduction. It is not in line with the cognitive law to introduce a knowledge point prematurely and not use it after the lecture, and readers will soon forget it.

This is a book to learn programming from scratch. Readers are not required to have any programming experience, but they should at least have the following qualities:

*

Familiar with the basic operation of Linux system. If you don't have this, please refer to other textbooks to learn the basic operation of Linux system, and then learn this book when you are proficient. Brother Bird's Linux private kitchen is said to be a good book on Linux system management and application. But you don't need to know a lot of system management techniques to learn this book, as long as you can use basic commands and install your own system and software package.

*

Have the mathematics level of graduating from high school. This book will use high school mathematics knowledge. In fact, if you don't have the math level of graduating from high school, you don't have to consider being a programmer. But it doesn't mean that just graduating from high school is enough to be a programmer. Let's just say that reading this book should be no problem. Mathematics is the most important accomplishment of programmers, and computer science is actually a branch of mathematics. If your math is poor, you need to make up for it in the future.

*

Have the English level of high school graduation. For the same reason.

*

I am deeply interested in the principles and essence of computers, not studying for employment or high salary, but really interested in learning everything clearly.

*

Be diligent in thinking. This book tries its best to clarify the dependence between concepts and strive for one-stop learning. Readers don't need to look through other books to find a definition of a concept, nor do they need to wander around in this book to find a concept. They just need to learn from front to back in order. However, one-stop learning is not equal to fool learning. Some chapters are difficult and need active thinking to understand. This book can save you time, but it can't think for you. Don't expect to learn by skimming like reading a novel.

Another book in C language. Well, why should I learn this book instead of Tan Haoqiang or K &;; r? Please comment

I won't comment on Tan Haoqiang's book. Teach students to include a. c file.

K & R is undoubtedly recognized as the most classic C language course in the world. Before the introduction of the C standard, K&; The first edition of R is the de facto C standard. After the release of the C89 standard, K & ampr published the second edition of the standard, but it has not been updated since then, so it cannot reflect the development of C language after C89 and the latest C99 standard. This book has made many supplements in this respect. As I said above, this book is not so much about C language as about the principles of computers and operating systems, while K &;; R is to speak C language for the sake of speaking C language, with different emphases and different content arrangements. K &; ampr is well written, with concise code and language, but unfortunately, only those who know C will appreciate it. R is not suitable for beginners, especially students with zero foundation.

Please comment on what this book is and what it is not.

This book includes three parts:

*

Introduction to c language. This paper introduces the basic C grammar to help readers who have no programming experience understand what a program is, how to write a program, cultivate programmers' thinking habits and find the feeling of programming. The first half is adapted from [ThinkCpp].

*

The essence of c language. Combining the principles of computer and operating system, this paper explains how to compile, link and run C programs, and comprehensively introduces the grammar of C language. The bit operation chapter is adapted from the lecture notes of Lin, an embedded education teacher in Asia, and the linked list and binary tree chapter are adapted from the lecture notes of Zhu, an embedded education teacher in Asia. This chapter of assembly language is adapted from [GroudUp]. In the last chapter of the book, it is mentioned that there are two ways to learn programming, one is bottom-up and the other is top-down. These two ways have their own advantages and disadvantages and need to be combined. So my idea of compiling this book is that the first part is top-down, the second part is bottom-up, and the third part can fill the gap in the middle. These three parts are all around the C language.

*

Linux system programming. This paper introduces the working principles of various Linux system functions and kernels. This chapter of Socket programming is adapted from the lecture notes of Wei, an embedded education teacher in Asia.

This book is positioned at the entry level. Although it has a lot of content, it is not an encyclopedia. Except for C language, not completely. Many references are listed in the book, which is the starting point for readers to further study. The first chapter of K & R is a whirlwind tour, which makes the whole book simple and then goes deeper one by one. This book can also be regarded as a whirlwind tour of the curriculum system of computer specialty. After learning this book, you will have an overall view, and then it should be easy to learn those reference materials.

Why do you want to learn C language on Linux platform? Isn't it good to learn C language with Windows? Please comment

You really can't learn C language with Windows. C language is a low-level programming language. To write a good C program, we must be very clear about the working principle of the operating system, because the operating system is also written in C, and we directly use the interface provided by the operating system to write applications in C. Since you chose to read this book, you must know that Linux is an open source operating system. You can find the answer to any question from the source code and documentation. Even if you can't read the source code and find the document, it's easy to find an expert to teach you. In various mailing lists, newsgroups and forums, there is always a lack of helpful experts. Windows is a closed operating system, and no one can see its source code except Microsoft employees, so we can only guess its working principle through documents. To make matters worse, Microsoft always likes to keep its hidden and easy-to-use functions for its own use, rather than writing documents for public use. The first part of this book can be studied on Linux or Windows platform, but the second and third parts introduce many principles of Linux operating system to help readers understand C language more deeply and can only be studied on Linux platform.

Development tools on Windows platform are usually associated with various integrated development environments (IDE), such as Visual Studio and Eclipse. It is really convenient to use IDE, but IDE is definitely not a good thing for beginners. Microsoft likes to promote the concept of fool programming, telling you to drag several controls with the mouse and then click a button to compile the program, but which really useful program is dragged out like this? Many people who learn programming from the Windows platform have been programming for several years, but they still only know that after programming, they can run by clicking a button and drag several source files into a project to compile them together. If there are more complicated requirements, they will be dumbfounded, because they only have the concepts of buttons and menus in their minds, but there are no concepts of compilers, linkers and Makefile, and even command lines. However, these are the basic concepts that beginners should establish when programming. On the other hand, compilers and connectors are closely related to the grammar of C language. If you don't understand the working principle of compiler and linker, you can't really master the grammar of C, so IDE doesn't help you learn, but hinders you from learning. It turns out that learning C programming well only requires learning grammar and compiling commands. Now, with IDE, besides learning grammar and compiling commands, you have to figure out how compiling commands and IDE are integrated, so that you can understand mathematics. IDE makes the already complicated learning task more complicated. The usage habit of Linux users has always been to type commands, supplemented by mouse operations. From the first day of learning programming, you should type commands to compile programs. When you make these basic concepts clear, which IDE do you think is convenient for you to use, but then you may prefer vi or emacs to IDE.