Programmer's path-how to learn C language and be proficient in C Language

Source: Internet
Author: User

Learning C language is not an overnight task, but it does not take ten years to become proficient. The topic of this article is how to learn and master C language at minimal cost. Please note that even the "minimum price" is by no means a shortcut, but it is the shortest time to get the most, it also means that you need to go through a difficult process.

1. read a good book; otherwise, it is better not to read

The first question for all beginners is how to choose teaching materials. A good start is half the success. Choosing a good teaching material is a key factor to get twice the result with half the effort. Unfortunately, schools usually help you specify a poor C language textbook. Fortunately, you can choose again.

Professor Tan haoqiang, a famous expert, wrote the C LanguageProgramDesign, it is said that there are more than 4 million circulation, as far as I know, many schools will recommend this book as a C language textbook. Although my name (TAN haoyu) is just a word different from that of the professor, I am very firm in hacking his book. This book is not intended for computer students, but for other students who need to take the computer level test. The main disadvantage of this book is that the example program is very unprofessional and cannot teach you the way of thinking that should be mastered in programming. The program style is rather bad and will lead you to write it in disorder.CodeBad habits. There are too many mistakes. Someone once pointed out hundreds of errors in this book, many of which are critical Conceptual errors. Well, I don't want to talk too much about this book. If you are interested, please refer to Baidu :)

Kernighan and Ritchie's "The C programming language" (Chinese translated as "C programming language") is a classicHowever, many of the old versions are outdated, which is far from the current standard C language. You must check the latest version; otherwise, you may as well leave it blank. In addition, even the most classic and authoritative books cannot cover all aspects. Therefore, it is necessary to keep a "C Language Reference Manual" at hand.C Language Reference Manual is c Reference Manual, which is a detailed description of C language standards, including the details of the vast majority of C standard library functions.. By the way, the latest C programming language is revised in accordance with the c89 standard, and the C Language Reference Manual describes the c99 standard, which may be somewhat different, we recommend that you follow the c99 standard. Another oneThe English name of "C and pointer" is also quite good.Especially emphasizing the importance of pointers is a feature of this book. However, this book is not very suitable for beginners. If you have studied C language and have some basic but not very solid C language, you can try it. I believe that as long as you understand the pointer, the C language is no longer mysterious.

If you have completed a C language textbook and want to go further, you must read two books. FirstC traps and pitfalls (translated in Chinese)A very thin booklet with very interesting content. Note that this book was written more than 20 years ago. Many defects in C language have been improved, but it is not a bad thing to understand some history. Then you can challengeExpert C ProgrammingThe book is as well as its name. This book is quite difficult. Once you finish reading it carefully and understand it thoroughly, You can confidently write "proficient in C Language" on your resume.

Keep in mind that it is a waste of life instead of reading books that you cannot understand. If you cannot understand it, you must have some basic knowledge. At this time, you need to carefully analyze what you need to add, and then go to the bookstore to find the books about the content. After completing the basic knowledge, you can get twice the result with half the effort.

Ii. Unix/Linux or windows, which is a big problem

Different programming environments will create programmers with different ideas. Windows programmers mostly rely on integrated development environments, such as Visual Studio, while UNIX programmers prefer makefile and console. Obviously, the integrated development environment is easier to use. To learn the C language on Windows, you only need to press several basic visutal C ++ toolbar buttons to start writing Hello, world! In UNIX, you need basic console operations. Some people may think that the Unix environment is more concise, but the power of habit is great. Everyone is familiar with the basic operations of windows, and to learn the C language, install a UNIX system, it seems a bit uneconomical.

For a newbie who only knows Basic Windows operations and does not even know what DOS is, it is most important to do interesting and meaningful things as soon as possible. Writing a small program in C language is far more interesting than learning commands such as LS and CAT. Besides, if we want to focus on C language itself, we have to temporarily ignore some things, for example, the process of compiling the link and writing makefile.

So I suggestBeginners should use visual c ++ 6.0 (not VisualC ++. net) or Dev C ++ as the main learning environment.And never get too entangled in IDE usage skills, because you must switch to the Unix environment in the future.Visual c ++ 6.0 is easy to use and intuitive to debug, but its default compiler does not support the C standard, while Dev C ++ uses the GCC compiler, good support for c99 standards. As mentioned above, many university C language courses are still using turboc 2.0 as an experimental environment, which is rather undesirable becauseFirst, TC 2.0 has almost no support for the C standard, and second, the program compiled by TC 2.0 is 16 bits, which will cause great troubles for the 32-bit program in the future.(Of course, using something like djgpp can make TC 2.0 compile a 32-bit program, but that's too complicated ).

After you finish learning a C language textbook, you must switch to the UNIX platform to continue learning. Almost all advanced C language tutorials are based on the UNIX platform (such as C expert programming). The process of transformation is painful. What you need to face is a variety of complicated commands, which are totally different from the way you think on Windows platforms, but this kind of pain is worth it. UNIX and C are symbiotic. The thinking and habits of UNIX are more in line with the thinking methods and habits of C language. In UNIX, you can find countless excellentSource codeYou can easily view the online manual of a library function and view the best code style.

To sum it up, we recommend that you use a Windows system and an integrated development environment when you are a beginner in C language. Please switch to the UNIX platform first when you are ready to work toward a "master.

3. Everything is ready. You are Dongfeng.

The book has been selected, and the Environment configuration is complete. Everything is ready, and you only owe your efforts.Read the teaching materials carefully from the preface of the book.Many people like to read the book directly from chapter 1, which is wrong.The preface is a general introduction to the entire book. The author generally tells you what foundation is needed to successfully read this book. This helps you to check whether your basic knowledge is ready.. After reading the preface, you also need to browse the directory to understand the overall structure of the book and arrange a learning plan for yourself.

To learn the C language, you must pay attention to every detail. You must repeat the example code in the book by yourself. The compilation, execution, and output must be consistent with the example code described in the book. If they are different, we need to carefully find the original cause. I have provided some examples in books and want to create some examples. For example, when learning the operator priority, I can write several identical expressions and add parentheses in different positions, let's look at the different behaviors, such as * P ++ and (* P) ++, and a = B = C, (A = B) = C and A = (B = C. Examples in the Self-copied books and the transformed examples, as well as examples of "creation", should be carefully classified and saved, and a brief comment should be written in the source code, describe the intention of this example.

The example is followed by an exercise., I suggest beginners do all the exercises independently, and then compare the answer code to see if your code has any shortcomings, and try again to modify your code. Many people do not pay attention to exercises. This is a huge mistake, because the author usually describes some important principles in the exercises, rather than simply testing the previous knowledge.

Maybe you think it is too slow to study. If you learn carefully, you don't have to go back. After you learn it, you will find that you haven't figured it out before. This is really not worth the candle. Generally speaking, after reading the entire book, you should complete thousands or even tens of thousands of lines of code. Whether it's just a copy of the book or something you just write on your own, it's a fortune to continue learning in the future. For example, when I read "Windows core programming" (I only read 3/4 of the content), I wrote many examples in addition to the Code on the copybook, there are a total of 5574 lines (using WC tools in UNIX). After several days, I can't remember Windows system programming, but I just need to take a few minutes to read the previous code, then it will become clear again. The so-called good memory is not as bad as a pen, this is the truth.

Read carefully, copy the source code carefully, complete the exercises independently, and perform further experiments. Finally, you can leave all the code behind to become your own experience and wealth. It is absolutely hard, and you can do more with less. Of course, this method is only suitable for learning technologies that require proficiency. If you are not studying C language, you need to analyze the specific situation.

At the end of the article, there is a very important point not mentioned-the Code style. From the very beginning, you must force yourself to imitate the best code style.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.