The C Language Learning Guide for UNIX and Linux

Source: Internet
Author: User
Tags manual time and date

Although the C language has been in existence for nearly 30 years, its charm has not diminished. The C language continues to attract a large number of developers who have to learn new skills in order to write, transplant, or maintain applications.

This article is written to meet the needs of beginners in C language or developers who want to improve their C language. Hope to help you with your study and work. You may not agree with some of these methods, but we hope you'll like some of them.

This article does not introduce as a programmer should master the language details, but with beginners to share their own UNIX C language programming learning experience, also does not indicate a qualified programmer should master computer knowledge, such as: operating system, data structure and algorithm, database and so on.

No matter what your purpose, I hope you can leave your comments or suggestions after reading this article. Your pertinent criticism will be the impetus for the author to move forward.

Tool articles

"The its prerequisite of good deeds," he said. Programming is a very practical work, in your future study or work, you will often deal with the following tools, listed below are learning C language programming often used in software and tools.

(i) Operating system

Learning C in a UNIX or Linux system is convenient, so please select a UNIX or Linux operating system before starting your learning journey.

Currently available for personal use, UNIX or Linux systems have FreeBSD, RedHat Linux, SUSE Linux, etc., and there are many useful tools available in the installation package, such as GCC, make, etc.

If you've been using Windows and you don't have any extra machines installed on UNIX, you can use VMware to install virtual systems through VMware.

(ii) Compilation tools

Most UNIX or Lnux systems currently offer CC or GCC compilers, and the simplest form of the CC command is as follows:

Cc-o Hello hello.c

Typing the above code in the UNIX shell environment compiles the HELLO.C program into an executable file hello.

Make tools such as GNU make, System V, and Berkeley make are the basic tools used to organize the application compilation process, but differ between each make tool.

Most UNIX and Linux programs are compiled by running make. The Make tool reads a file that contains instructions (the name of the file is usually makefile or makefile, but in the latter context we call it "makefile") and performs various actions to compile the program

(iii) Debugging Tools

The simplest debugging tool: Add print statements for your program

After you have a certain understanding of the operating mechanism of the program, you can use a number of tools to help you debug, of course, you have to learn these tools to be used, such as: Dbx,gdb.

There are also some memory tools to help you find memory leaks or buffer overflow problems, such as: MEMWATCH,YAMD, etc.

(iv) Other tools

1.vi or Vim

UNIX below this editor. Mainly rely on a bunch of commands to edit text files, learn UNIX programming best familiar with and skilled use VI editor.

Of course, in actual work, you may need an integrated coding environment or a powerful graphical editing tool.

Provide a Chinese vim online manual: http://vcd.gro.clinux.org/

2.netterm

One of the most famous network terminal software can use it to connect to the host system conveniently.

3.Secure Shell

A client-side tool that supports the SSH protocol and is used in most cases to connect to the Linux system.

Book Articles

"The book is the ladder of human progress." Learn a new knowledge, of course, to choose a few suitable for their own books, here are some of my own learning C language used books:

1. "C Primer Plus"

Recommended reasons: Suitable as a primer and basic function query reference. The latest edition of this book is the fifth edition, with ANSI C99 as the standard detailed introduction of C language.

2. "The C programming_language"

Reason for recommendation: The father of the language of C has the authority to work without doubt. Although the book publishing time is relatively old, it seems to have not updated, but it is still a classic book, online has the book to download the English version.

3. "C Expert Programming"

Recommended reasons: This book can help have some experience C programmer to become a C programming experts, the most important is this book entertaining, let you fully enjoy the fun of programming.

4. "C Defects and pitfalls"

Reason to recommend: The knowledge revealed in the book can help you circumvent the pitfalls and pitfalls of C itself and reduce many of the common bugs in your code.

5. Advanced Programming of UNIX environment

Recommended reason: Since it is the UNIX environment C programming, process Chapter

1. Learn C Grammar

Grammar learning is easy for a programming foundation; even if you haven't learned any other programming languages before, I'm sure you'll be able to handle them in 2 weeks.

Note that you should not dwell too much on the details of the language, such as operator precedence and binding problems.

2. Learn C standard library

The ANSI C library divides functions into different groups, each with a header file associated with them. C Language standard library relative to other languages, such as C++,java is very short, but first should focus on the following library to learn:

Ctype.h: Character processing

MATH.H: Math Library

Stdio.h: Standard I/O Library

Stdlib.h: Common Tools Library

String.h: String Handling

Time.h: Time and date

If you want to learn about the finished ANSI C library, you can purchase the relevant books, which will generally detail the users and some points of attention of each function, but you can also login to http://www.dinkumware.com/manual ... amp;page= Index.html get ANSI C library details.

3. The difficulty of conquering C

C Language statement:

The C language statement really makes me feel horrible, more obscure, and the form of the Declaration and the form of use is similar. For example, the following statement I am afraid even many familiar with the C years of programmers are not a glance can be seen:

char * const * (*next) ();

So is there a good memory method or rule to figure it out, as if not, if there is no such torture. But you can take a look at the "C Expert programming" chapter III of the content, perhaps you will gain. can only learn more training, the so-called practice makes perfect, I hope this problem does not leave a shadow on your mind.

Arrays and pointers:

The relationship between the array and the pointer, in the standard does not make very detailed provisions, and a lot of C-entry books on this issue did not give a very detailed explanation, so it will cause a lot of misunderstanding.

For this issue, you can refer to "C Bug and Trap" section 4.5 and "C Expert programming" chapter 4,9,10, I believe that the contents of your thorough, the future will not be confused by this problem.

Pointers and Memory:

If you write larger programs in the future, you may find that this problem may be your biggest annoyance, and may be the most important debugging time you can consume.

C version of the problem:

You have to be particularly careful with this problem, it is best not to mix different versions of C in your program, otherwise it will give you a confusing problem. If you must use it, you'd better know what you're doing.

There are some other difficulties in C and easy to mistake places, you can learn from the predecessors of some experience. The following is a link to the C FAQ, which is believed to have a solution for most of the problems you need in this document.

http://c-faq-chn.sourceforge.net/

4.UNIX Environment Programming

After learning the above, I believe that you will be able to program the UNIX environment. But you might want to learn a little bit about the theory of operating systems, which makes it easier to learn.

UNIX environment programming, you should focus on IO and process two chunks of content. UNIX environment advanced Programming in the UNIX environment programming has a very detailed and in-depth discussion, and the book has a lot of practical examples of procedures, but it may take a few months time, a good bite.

In the solid grasp of the above content, does not mean that you have to C language learning slip has been completed, on the contrary, has just begun. Later you need to learn to solve a lot of different practical problems, in the continuous practice process, you will be a step closer to the understanding of C. With the above foundation, you will find that the other knowledge you need in the course of practice will be mastered very quickly.

Method article

Programming is a very practical work, the best way to learn is to read while debugging the code, the book on the example of the program repeatedly modify the debugging run, from which to get their own experience. In their own study or work to write a number of test procedures, to classify the preservation of the actual work in the future, the continuous collation, accumulated over time is a good resource pool.

Sometimes, it may be found that the examples in the book are easier to understand when understanding the concept, but the practical value is not high. So to improve their programming ability, you also need to learn other people's code, I think that the study of other people's code is to improve their actual programming ability the best and fastest way, now there are many valuable open source code on the network for you to choose to learn.

Finally, one problem that has to be mentioned is that you should never let yourself drown in the ocean of technical details, such as prefix + + operator problems, expression calculation priority issues, and so on.

Learning Unix under C programming or other programming languages, our final goal is to use the computer to solve the problem in reality, so the accumulation of daily work in common problems in the solution, and form a certain paradigm, do some refining is the most important. In the final analysis, the design and programming of the thing, is the methodology, whether you are unconscious or conscious, so be sure to pay attention to accumulation.

Supplementary notes

1. It is not necessary for the general developer to ask if an ANSI C99 standard is required, and not to say that its language is obscure, even if you can learn it from beginning to end, I don't think there is any improvement to your programming.

2. At present, most Unix operating systems with the CC, GCC and other compilers do not seem to support all the new features of C99, but now there are enough new features universally available, so there is reason to start seriously consider the use of new development C99 features, This is especially true where they make the change in efficiency or clarity inherently different (such as inline functions instead of macro replacements).

3. Programming specifications of the problem: generally more formal software companies will have their own set of complete programming specifications, then you observe the good; If you are learning, you can choose a more general specification, the best way is to see how others write code.

You have to talk about Unix programming books. Mr. Stevens's "UNIX Environment Advanced Programming" is my recommended, but also my desk (if you are interested in network programming, you can learn about Mr. Stevens's "UNIX Network Programming" two volumes, if it is not enjoyable, you can take a look at "TCP/IP detailed" three volumes).

6. The Art of computer programming

Recommended reason: The algorithm master has to work. It is planned to publish five volumes and it appears that 3 volumes have been published. Be interested in the algorithm can be studied.

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.