How to learn C language

Source: Internet
Author: User

Learning C language is not a matter of overnight, but it does not take 10 years to master. How to learn and Master C language at the minimum cost is the subject of this article. Note that even the "minimum price" is not a shortcut, but the most rewarding in the shortest possible time, and it also means that you need to go through a tough process.

Read good books, or you should not read them.

The first question that all beginners face is how to choose teaching materials. A good beginning is half the success, and choosing an excellent textbook is a key factor in the effort. Unfortunately, schools usually help you designate a poor C language textbook, and fortunately, you can choose again.

The famous Professor Tan Haoqiang a "C language program," said the circulation of more than 4 million, as far as I know, many schools will recommend this book as a C language textbook. Although my name (Tan Haoyu) and professor only one word of the difference, but I was extremely determined to black his book. This book is not written for computer majors, but for other majors who need to take a computer-grade test. The main disadvantages of this book are: Example program is very unprofessional, can not teach you the design should master the way of thinking; program style is not good local, will let you develop the bad habit of writing code, there are too many mistakes, some people have pointed out the book hundreds of errors, including a number of key conceptual errors. Well, this book I do not want to say too much, interested you can Baidu:

Kernighan and Ritchie's "The C Programming Language" (in the translation of "C programming language") is a classic classic, but the old version of a lot of content are outdated, and now the standard C language is far from, we must see the latest version, Otherwise, it's better not to look. In addition, even the most classic and authoritative book, there is no way to do everything, so it is necessary to have a copy of the "C Language reference manual." "C Language Reference manual" is "C Reference Manual", is a detailed description of the C language standard, including the vast majority of the C standard library function details, is the best standard C language tool. Incidentally, the latest "C programming language" is revised according to the C89 standard, and the "C Language Reference manual" describes the C99 standard, the two may be some discrepancies, recommended to follow the C99 standard study. There is also a "C and pointers", written is also quite good, the English name is "pointers on C", especially to emphasize the importance of pointers, is a feature of this book. But this book is not very suitable for beginners, if you have learned C language, there are some C language basis but not very solid, then you can try this book. I believe that as long as you understand the pointer, C language is no longer mysterious.

If you have finished a C language textbook and want to go further, there are two books you must see. The first is "C Traps and Pitfalls" ("C Trap and defect"), a very thin booklet, very interesting. Note that the book was written more than 20 years ago, and many of the C-language flaws mentioned here have been improved, but it is not bad to be able to understand some history. Then you can challenge the "Expert C Programming" (the translation of "C expert programming"), the book as its name, the book is quite difficult, once you carefully read and can understand thoroughly, you can confidently boldly on the resume to write "proficient in C language."

Remember a principle, do not read the book that you do not understand at present, it is a waste of life. If you do not understand, then you must be missing some of the necessary basic knowledge. At this point, you should carefully analyze what you need to add, and then go to the bookstore to find the content of these books. The basic knowledge to complete and then back to learn, will really be more effective.

Second, unix/linux or Windows, this is a big problem

Different programming environments create different thinking programmers. Most Windows programmers rely on an integrated development environment, such as visual Studio, where UNIX programmers are more fond of makefile and consoles. Obviously, the integrated development environment is easier to get started with, learning C on Windows, just by pressing a few basic Visutal C + + toolbar buttons to start writing Hello, world! , and under UNIX, you need some basic knowledge of console operations. Some people may think that the UNIX environment is more concise, but the force of habit is very big, everyone is very familiar with the basic operation of Windows, and in order to learn C language to install a UNIX system, it seems a bit uneconomical.

For a novice who only understands the basics of windows and doesn't even know what DOS is, it's important to do something interesting and meaningful as quickly as possible. In C language to write a small program is far more interesting than learning LS, cat and other commands, and we have to focus on the C language itself, we have to temporarily ignore some things, such as the process of compiling links, makefile and so on.

So I suggest that beginners should be in Visual C + + 6.0 (not visualc++. NET) or Dev C + + as the primary learning environment, and do not dwell too much on the IDE's usage skills, because you will have to turn to UNIX environments in the future. Visual C + + 6.0 is easy to use and debugging is intuitive, but its default compiler does not support the C standard, and Dev C + + uses the GCC compiler to support C99 standards. By the way, many universities ' C language courses are still using Turbo C 2.0 as an experimental environment, which is rather undesirable because TC 2.0 has little support for the C standard, and the second is that TC 2.0 compiles a program that is 16-bit, This will cause great trouble to understand the 32-bit program in the future (of course, things like DJGPP can make TC 2.0 compile 32-bit programs, but that's too complicated).

When you finish learning a C language textbook, you must turn to the UNIX platform to continue to learn, almost all of the C language advanced tutorials are based on UNIX platform (such as "c Expert programming"). The process of transformation is painful, you need to face a variety of complex commands, completely different from the Windows platform of thinking, but the pain is worth it. UNIX and C are symbiotic, Unix thinking ways and habits more in line with the C language of thinking and habits. Under UNIX, you can find countless good source code for you to read, you can easily view the online manual of a library function, and you can see the best code style

It boils down to a sentence: Beginners C language, the proposed use of Windows system and integrated development environment, in preparation for the "master" in the direction of efforts, please first turn to the UNIX platform.

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.