本文由 伯乐在线 - 艾凌风 翻译。未经许可,禁止转载!
英文出处: Steve Emms。欢迎加入翻译组。
Books are very personal things. And programming books are no exception. We all form bonds with programming books that help master the rudiments of a language, and then be able to move on to fully exploit the language’s flexibility.
I have carefully considered the open source C books that are closest to my heart. I have identified 9 books that mean the most to me.
书是非常私人的东西,编程类书籍也不例外。我们都是通过阅读书籍来帮助我们掌握某种语言的基本知识的。随后我们又通过,阅读书籍来探索这门语言的灵活性。我仔细的考察了一些我最喜爱的c语言书籍并从其中选出了对我意义最大的九本。
C is a general-purpose, procedural, portable, high-level programming language that is one of the most popular and influential languages. It was designed to be compiled using a straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. Many programming languages owe a considerable debt to C. It has become something of the lingua franca in the programming world.
c语言是一种通用的、面向过程的高级编程语言。也是最具流行度和影响力的编程语言之一。该语言在设计时就被设计为可以通过编译器进行编译,以此来对内存进行底层操作并高效的执行机器指令以及在运行时仅需要最小的支持。很多很多编程语言都得益于c语言。c语言就像是编程界的通用语言一样。
C is fairly simple to understand. It allows the programmer to organize programs in a clear, easy, logical way. It is a very flexible, practical and compact language combined with an easy to read syntax. Code written in C runs quickly, with easy access to the low level facilities in the computer. Compiler directives make it possible to produce a single version of a program compiled for different architectures.
c语言非常易懂。它允许程序员,能够以一种简洁、简单、符合逻辑的方式来组织程序。这是一种非常灵活、实用并且简洁的语言,同时它还具有非常,容易读懂的语法。使用c语言编写的代码运行非常快。可以非常简单的操作计算机的底层设施。通过编译器的指令可以允许我们为不同体系结构的设备生成同一个版本的程序。
C is about freedom. It therefore makes sense to learn C with books that also embody freedom. Take a look at my open source picks and see if any of them grab your fancy. Put the kettle on and enjoy.
c语言是自由的。因此学习c语言的书籍,也是自由的。快来看看我挑选的开源书籍,有没有哪一本能够吸引你?好好享受它吧!
The C Book
《C语言》( The C Book)
作者: Mike Banahan, Declan Brady 和 Mark Doran ,350 页
The C Book is designed for programmers who already have some experience of using a modern high-level procedural programming language. The book concentrates on the things that are special to C. In particular, it is the way that C is used which is focused on.
这本书是为那些已经具备使用现代高级面向过程编程语言的程序员设计的。这本书专注于那些c语言的特有之处。尤其是使用c语言的方式是这本书所重点关注的。
Chapters include:
包含以下章节:
-
An Introduction to C Variables and Arithmetic – introduces some of the fundamentals of C, including keywords and identifiers, declaration of variables, real types, integral types, expressions and arithmetic, and constants
-
Control of Flow and Logical Expressions – looks at the various ways that the control of flow statements can be used in a C program, including some statements that have not been introduced so far. Control of flow, more logical expressions, and strange operators
-
Functions – the type of functions, recursion and argument passing, and linkage
-
Arrays and Pointers – arrays, pointers, character handling, sizeof and storage allocation, pointers to functions, expressions involving pointers, arrays, the & operator and function declarations
-
Structured Data Types – structures, unions, bitfields, enums, qualifiers and derived types, and initialization
-
The Preprocessor – how the preprocessor works, and directives
-
Specialized Areas of C – declarations, definitions and accessibility, typedef, const and volatile, and sequence points
-
Libraries – diagnostics, character handling, localization, limits, mathematical functions, non-local jumps, signal handling, variable numbers of arguments, input and output, formatted I/O, character I/O, unformatted I/O, random access functions, general utilities, string handling, and date and time
-
Complete Programs in C – putting it all together, arguments to main, interpreting program arguments, a pattern matching program, and a more ambitious example
-
变量及运算法则介绍 – 介绍了 C 语言的基础知识, 包括关键字和标识符,变量声明,实数类型,整型,表达式和运算法则以及常量
-
控制流及逻辑表达式 – 这一章介绍了在C语言中可以用于控制程序流程的几种方法,包括一些尚未介绍的语句。 控制流,逻辑表达式以及奇怪的运算符。
-
函数 – 函数的类型, 递归,传参数以及链接
-
数组和指针 – 数组, 指针, 字符处理, sizeof 以及储存空间分配, 函数指针,包含指针的表达式,数组,
&
运算符以及函数声明 -
结构体数据类型 – 结构体, 联合体, 位字段, 枚举类型, 限定符、派生类型以及初始化
-
预处理器 – 预处理器是如何工作的及其相关指令
-
C 语言中的一些特定内容 – 声明, 定义,
typedef
,const
和volatile
以及序列点 -
库 – 诊断, 字符处理, 本地化, 与具体实现相关的限制, 数学函数, 非局部跳转, 信号处理, 可变参数, 输入输出, 格式化 I/O, 字符 I/O, 无格式 I/O, 随机访问函数, 通用函数, 字符串处理, 日期和时间
-
C语言编写的完整程序 – 综合以上内容, main函数的参数, 解析程序参数, 模式匹配程序以及一个难度更大的程序
The authors give the reader permission to do anything they want with the book provided there is an acknowledgement of the authors and their copyright. From what Mike Banahan has confirmed, the book is effectively under the Creative Commons License.
作者允许读者利用此书做任何他们想做的事情,只需说明作者和版权。经Mike Banahan确认,本书通过知识共享协议发布。
C Elements of Style
风格的要素——C语言版(C Elements of Style)
By Steve Oualline (265 pages)
作者 Steve Oualline ,265页
C Elements of Style is a useful guide which covers the principals of good programming style, teaching C and C++ programmers how to write code that can be easily read, understood, and maintained by others. Whether you are a student or professional programmer, you will benefit from the many tips and techniques for constructing elegant, reliable code.
这是一本十分有用的涵编程风格指南,指导c和c++程序员如何去编写可读性良好的,易懂的,易于维护的程序。不论你是一个学生还是专业程序员,你都能从这本书中提供的技巧和技术中获益,构建优雅可靠的代码。
The book attempts to show readers how to build a good programming style into your code. Since computer reads only the code and the human concentrates on the comments, a good programming style pertains to both parts of a program.
这本书意在向读者们展示如何在你的程序中融入风格良好的代码。机器仅处理代码,而人类关注于注释。良好的编程风格与这两部分都有关。
The ultimate goal is to build a well-designed, well-written code which not only make an effective use of the computer and but also contains careful constructed comments to help humans understand it. This condition will ease the debugging, maintenance and enhancement process, which will eventually improve the readability, portability, reliability and maintainability of your code.
我们的最终目标是构建设计良好,编写良好的代码,这种代码对于计算机来说是高效的,同时包含了精心编写的注释用于帮助人类理解程序。这样一来,调试,维护和增强程序,都变得更加容易了。最终还提升了代码的可读性,简洁性,可靠性和可维护性。
Inside, you will find guidelines on writing comments, program heading, determining variable names, statement formatting, statement details, writing preprocessor, organizing directories and creating makefile.
在本书中,你可以找到有关编写注释,程序头,变量命名,语句格式化,语句细节,编写预处理器命令,组织目录和创建makefile的指南。
This book is published under the Creative Commons License.
本书通过知识共享协议发布。
Build Your Own Lisp
《编写你自己的Lisp语言》(Build Your Own Lisp)
By Daniel Holden (212 pages)
作者 Daniel Holden ,212页
Learn the C programming language and at the same time learn how to build your very own programming language, a minimal Lisp, in under 1000 lines of code.
在学习C语言的同时学习如何创造你自己的编程语言——一个最简的Lisp语言(仅用不到1000行代码)。
This book is for anyone wanting to learn C, or who has once wondered how to build their own programming language. It is not designed as a first programming language book, as you need some programming experience to make your way through the content.
这本书是为两种人写的,一种是想要学习c语言的人,另一种是想要知道如何创建一门语言的人。本书并不适合作为第一本入门书籍,因为你需要一些编程经验才能读懂它的内容。
Build Your Own Lisp is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0.
本书基于Creative Commons Attribution-NonCommercial-ShareAlike 3.0.协议发布
A paperback is available to purchase from Amazon.
纸质版可以在Amazon上购买。
The GNU C Reference Manual
《 GNU C语言参考手册》(The GNU C Reference Manual)
By Trevis Rothwell, James Youngman (91 pages)
作者 Trevis Rothwell, James Youngman ,91页
The GNU C Reference Manual is a reference for the C programming language and aims to document the 1989 ANSI C standard, the 1999 ISO C standard, and the current state of GNU extensions to standard C. It is not designed for new programmers.
本书是一本C语言参考手册,意在写明C89,C99标准以及当前GNU对标准c语言的扩展情况。本书并不适合新手阅读。
Chapters cover:
包含以下章节:
-
Lexical Elements – describes the lexical elements that make up C source code after preprocessing. These elements are called tokens. There are five types of tokens: keywords, identifiers, constants, operators, and separators
-
词法元素——这部分内容描述了预编译之后,组成 C 语言代码的词法元素。包括5种:关键字,标识符,常量,操作符和分隔符
-
Data Types – examines primitive data types, enumerations, unions, structures, arrays, pointers, incomplete types, type qualifiers, storage class specifiers, and renaming types
-
数据类型——研究基础的数据类型,枚举,联合体,结构体,数组,指针,不完全类型,类型修饰词,储存类型修饰词以及重命名类型
-
Expressions and Operators – also looks at incrementing / decrementing, arithmetic operators, complex conjugation, comparison operators, logical operators, bit shifting, bitwise local operators, pointer operators, the sizeof operator, type casts, and more
-
表达式和操作符 —— 还介绍了自增/自减,算数操作符,复共轭性,比较操作符,逻辑运算符,位移,位运算符,指针运算符,
sizeof
,类型转换等等。 -
Statements – read about labels, expression statements, the if statement, the switch statement, the while statement, the do statement, the for statement, blocks, the null statement, the goto statement, the break statement, the continue statement, the return statement, and the typedef statement
-
语句 —— 标签,表达式,
if
语句,switch
语句,while
语句,do
语句,for
语句,代码块,null
语句,goto
语句,break
语句,continue
语句,return
语句以及typedef
语句 -
Functions – learn about function declarations, function definitions, calling functions, function parameters, variable length parameter lists, calling functions through function pointers, the main function, recursive functions, and more
-
函数 —— 学习函数声明,函数定义,函数调用,参数,边长参数列表,通过指针调用函数,
main
函数,递归函数等等。 -
Program Structure and Scope – looks at the big picture
-
程序结构和定义域 —— 从宏观上来看程序
-
A Sample Program – a complete program written in C, consisting of both a C source file and a header file. This program is an expanded version of the quintessential “hello world” program, and serves as an example of how to format and structure C code for use in programs for FSF Project GNU
-
一个例程 —— 一个用 C 语言编写的完整程序,包含 C 语言源文件和头文件。这个程序是一个典型“hello world”程序的扩展版,它向我们展示了在 GNU FSF 项目中 C 语言是如何工作的。
The book is available under the terms of the GNU Free Documentation License, Version 1.3 or later.
本书基于GNU Free Documentation License Version 1.3 及其更新版本发布。
The GNU C Programming Tutorial
《GNU C 语言编程教程》(The GNU C Programming Tutorial)
By Mark Burgess, Ron Hale-Evans (290 pages)
作者 Mark Burgess, Ron Hale-Evans ,290页
The GNU C Programming Tutorial introduces the reader to the basic ideas in a logical order. It offers detailed coverage of each of the main elements of the C language and how to program in C, with special emphasis on the GNU/Linux compiler and associated software.
本书以逻辑顺序向读者介绍了 C 语言的基本内容。本书内容涵盖了 C 语言的全部主要内容的细节以及如何使用 C 语言编程,特别强调了GNU/Linux编译器以及相关软件。
There are chapters devoted to functions, variables and declarations, scope, expressions and operators, parameters, pointers, decisions, loops, arrays, strings, input and output, and much more.
一些章节主要介绍了函数,变量以及声明,作用域,表达式和操作符,参数,指针,判定,循环,数组,字符串,输入输出等等。
The GNU C Programming Tutorial is released under the GNU Free Documentation License, Version 1.1.
本书基于GNU Free Documentation 协议 Version 1.1版发布。
Essential C
《C语言基础》(Essential C)
By Nick Parlante (45 pages)
作者 Nick Parlante ,45页
This Stanford CS Education is a fairly brief document which explains all the common features and techniques for C. The coverage is pretty quick, so it is targeted at a programmer with a background in another language.
这份简短的文档解释了 C 语言全部的常用特性和技术。这份文档十分简洁,因此它的目标人群是已经具有其他编程语言背景的人。
Topics include variables, int types, floating point types, promotion, truncation, operators, control structures (if, while, for), functions, value parameters, reference parameters, structs, pointers, arrays, the pre-processor, and the standard C library functions.
内容包括变量,整型,浮点型,类型提升,截断,操作符,控制结构(if
,while
,for
),函数,数值参数,引用参数,结构体,指针,数组,预处理器以及 C 语言标准库函数。
Table of Contents:
Introduction
Basic Types and Operators
Control Structures
Complex Data Types
Functions
Odds and Ends
Advanced Arrays and Pointers
Operators and Standard Library Reference
目录:
-
简介
-
基础类型与运算符
-
控制结构
-
复杂数据类型
-
函数
-
杂项
-
高级数组与指针
-
运算符和标准库
The author’s description indicates this book is issued under an open-source like license.
根据作者的描述,我们得知这是一本基于开源协议发布的书籍。
Beej’s Guide to C Programming
《Beej的C语言教程》(Beej’s Guide to C Programming)
By Brian “Beej” Hall (130 pages)
作者 Brian “Beej” Hall ,130 pages
Beej’s Guide to C Programming tries to lead the reader from complete and utter sheer lost confusion on to the sort of enlightened bliss that can only be obtained though pure C programming.
本书试图为那些心存困惑的读者带来一种仅能通过纯粹c语言编程而产生的快感。
Chapters:
章节:
-
Programming Building Blocks
-
构建程序的基本结构块
-
Variables, Expressions, and Statements – A variable is simply a name for a number. An expression in C consists of other expressions optionally put together with operators. Examines the if, while, do-while, and the for statements Building Blocks Revisited
-
变量,表达式和,语句。变量就是一个数字的名字。
一个c语言表达式可以包含其他的表达式以及运算符。文章还介绍了if
,while
,do while
以及程序重复执行的for
语句。
-
Functions – put some of those building blocks in their own functions when they become too large, or when they do a different thing than the rest of the code
-
函数。当程序块变得很大,或是当这些程序块用来执行一些特定的工作时,我们会把它们封装到函数中。
-
Variables, the Sequel – talks about variable scope and storage classes
-
变量(续篇)。探讨了变量的作用域和储存类型
-
Pointers – they are the address of data. Just like an int can be 12, a pointer can be the address of data
-
指针。它们是数据在内存中的地址。就像一个整型的值可以是12,一个指针的值就是数据在内存中的地址
-
Structures – a construct that allows you to logically group variables into groups. You can then reference the group as a whole
-
结构体。结构体允许你将变量分组。随后你可以将其作为一个整体来使用。
-
Arrays – a linear collection of related data
-
数组。一组相关数据的线性集合
-
Strings – a string in C is a sequence of bytes in memory that usually contains a bunch of letters
-
字符串。c语言中的字符串就是内存中的一组连续的比特,包含了一组字符
-
Dynamic Memory – explores the malloc(), free(), realloc(), and calloc() functions
-
动态内存。探讨了malloc(), free(), realloc() 和 calloc() 函数
-
More Stuff – topics include pointer arithmetic, typedef, enum, struct declarations, command line arguments, multidimensional arrays, casting and promotion, incomplete types, void pointers, NULL pointers, and static keywords
-
更多内容。指针运算,
typedef
,枚举,结构体声明,命令行参数,多维数组,类型转换和类型提升,不完整类型,void
指针,NULL
指针和static
关键字 -
Standard I/O Library – used for reading from and writing to files
-
标准输入输出库。用来进行文件的读写。
-
String Manipulation – find functions for pulling substrings out of strings, concatenating strings together, getting the length of a string, and more
-
字符串操作。用来查找子串的函数,连接字符串的函数,获取字符串长度的函数,等等。
-
Mathematics – functions that will serve your general purpose mathematical needs
-
一些可以满足你基本算数需求的函数。
This book is licensed under the Creative Commons Attribution-Noncommercial- No Derivative Works 3.0 License.
本书基于Creative Commons Attribution-Noncommercial- No Derivative Works 3.0 协议发布。
Modern C
《现代C语言》(Modern C)
By Jens Gustedt (310 pages)
作者 Jens Gustedt ,310页
Modern C seeks to motivate the reader to climb to higher levels of knowledge. The book is divided into five levels:
本书鼓励读者逐级探索c语言的特性。内容一共分为如下五个层级:
-
First level – provides the reader with the very basics of C programs, their purpose, their structure, and how to use them
-
第一层——使读者了解最基本的c语言程序。了解使用c语言的目的和数据结构,以及如何去使用它们
-
Second level – details most principal concepts and features such as control structures, data types, operators and functions. It aims to provide the reader with a deeper understanding of the things that are going on with running programs
-
第二层——详细的说明了大部分主要概念以及特性,包括控制结构,数据类型操作符和函数。这一级的主要目的是让读者能够对于这些运行程序必备的知识,有更深刻的理解。
-
Third level – goes to the heart of the C language. It fully explains pointers, familiarizes you with C’s memory model, and allows you to understand most of C’s library interface.
-
第三层——进入c语言的核心部分。详细的解释了指针,让你熟悉c语言的内存模型,并且让你了解大多数c语言库的接口
-
Fourth level – goes into detail in specific topics, such as performance, reentrancy, atomicity, threads and type generic programming
-
第四层——深入理解一些特定的主题。比如性能,重入,原子性,线程及泛型编程
-
Fifth level – discusses the author’s ideas for a future development of C
-
第五层——探讨了作者对这门语言未来发展趋势的理解
This book is licensed under the Creative Commons Attribution-Noncommercial- No Derivative Works 3.0 License.
本书基于Creative Commons Attribution-Noncommercial- No Derivative Works 3.0 协议发布
An Introduction to GCC
《GCC简介》(An Introduction to GCC)
By Brian Gough (144 pages)
作者 Brian Gough ,144页
An Introduction to GCC provides an introduction to the GNU C and C++ Compilers, gcc and g++, which are part of the GNU Compiler Collection (GCC).
本书介绍了 GNU C 语言和 C++编译器——gcc 和 g++,它们是 GNU 编译器套装(GCC)的一部分。
This book explains how to use the compiler itself. Based on years of observation of questions posted on mailing lists, it guides the reader straight to the important options of GCC.
本书介绍了如何使用编译器。通过多年以来对邮件列表中的问题的观察,本书带领读者直击 GCC 的重要选项。
Chapters:
章节介绍:
-
Compiling a C program – describes how to compile C programs using gcc. Programs can be compiled from a single source file or from multiple source files, and may use system libraries and header files
-
编译c程序。介绍了如何使用gcc来编译c语言程序。单个文件或多个文件均可以编译,也可以使用操作系统函数和头文件。
-
Compilation options – describes other commonly-used compiler options available in GCC. These options control features such as the search paths used for locating libraries and include files, the use of additional warnings and diagnostics, preprocessor macros and C language dialects
-
编译选项。介绍了gcc中一些常用的编译选项。这些参数控制一些功能,例如搜索库函数和头文件的路径,提供额外的编译告警和诊断。预处理宏和c语言方言。
-
Using the preprocessor – describes the use of the GNU C preprocessor cpp, which is part of the GCC package. The preprocessor expands macros in source files before they are compiled. It is automatically called whenever GCC processes a C or C++ program
-
使用预处理器。描述了cpp(GNU C preprocessor)的使用方法,cpp是GCC的一部分。预处理器会在编译前将代码中的宏展开,当GCC处理c或者c+代码时,预处理器会自动被调用。
-
Compiling for debugging – provides the -g debug option to store additional debugging information in object files and executables. This debugging information allows errors to be traced back from a specific machine instruction to the corresponding line in the original source file
-
编译带有debug信息的程序。提供了一个
-g
选项用以在中间文件和可执行文件中存储额外的调试信息。这些调试信息使得我们可以追踪错误,将机器指令中的问题定位到源代码中。 -
Compiling with optimization – GCC is an optimizing compiler. It provides a wide range of options which aim to increase the speed, or reduce the size, of the executable files it generates
-
优化编译。GCC是一个优化过的编译器。它提供了很多选项,可以加速编译或是减少编译后文件的体积。
-
Compiling a C++ program – describes how to use GCC to compile programs written in C++, and the command-line options specific to that language
-
编译C++程序。介绍了如何使用GCC编译C++程序以及该语言可以使用的命令行选项。
-
Platform-specific options – describes some of the options available for common platforms: Intel and AMD x86 options, x86 extensions, x86 64-bit processors, DEC Alpha options, SPARC options, POWER/PowerPC options, Multi-architecture support, and floating-point issues
-
平台相关选项。介绍了一些常见平台可以使用的选项
-
Troubleshooting – GCC provides several help and diagnostic options to help troubleshoot problems with the compilation process
-
排错。GCC提供了一些帮助和诊断选项用于帮助我们定位编译过程中出现的问题。
-
Compiler-related tools – describes a number of tools which are useful in combination with GCC. These include the GNU archiver ar, for creating libraries, and the GNU profiling and coverage testing programs, gprof and gcov
-
编译器相关工具。介绍了GCC编译过程中会用到的一些有用的工具。包括用来创建库的 GNU 归档工具 ar,GNU 性能和覆盖率测试程序gprof 和 gcov
-
How the compiler works – describes in more detail how GCC transforms source files to an executable file. Compilation is a multi-stage process involving several tools, including the GNU Compiler itself (through the gcc or g++ frontends), the GNU Assembler as, and the GNU Linker ld. The complete set of tools used in the compilation process is referred to as a toolchain
-
编译器是如何工作的。详细介绍了GCC是如何把源文件编译为可执行文件的。编译是一个多阶段过程,涉及很多工具,包括GNU编译器本身,GNU汇编器,以及GNU链接器。在编译过程中使用的各种工具,我们统称为编译链。
-
Examining compiled files – describes several useful tools for examining the contents of executable files and object files
-
检查编译后的文件。介绍了一些用来检查可执行文件和obj文件内容的工具。
-
Common error messages – describes the most frequent error and warning messages produced by gcc and g++. Each case is accompanied by a description of the causes, an example and suggestions of possible solutions
-
常见错误信息。介绍了gcc和g++产生的最常见的错误和告警信息。每种情况都带有原因分析,样例以及建议的解决办法。
-
Getting help – if readers encounters a problem not covered by this introduction, there are several reference manuals which describe GCC and language-related topics in more detail
-
获取帮助。如果读者遇到了书中没有提到的问题,还有很多介绍GCC和语言的手册可以参考。
This book is published under the GNU Free Documentation License
本书基于GNU Free Documentation协议发布
Here are some informative C Books to download without charge, but which regrettably are not released under an open source license, or where license information is unclear. In no particular order:
很多c语言书籍都可以免费下载,但是可惜的是它们并没有以开源协议来发布,或其基于何种协议并没有明确说明。以下对其进行介绍,排名不分先后:
-
《C编程导论》 Introduction to C Programming – 作者 Rob Miles
-
《新标准C语言》The New Standard C: An Economic and Cultural Commentary – 作者 Derek M. Jones
-
《使用标准C语言进行面向对象编程》Object-Oriented Programming with ANSI-C – 作者 Axel-Tobias Schreiner
-
《编写零缺陷的C语言代码》Writing Bug-Free C Code – 作者 Jerry Jongenius
And finally, my recommendation if you want to buy a canonical reference book is this title: The C Programming Language. Terse, not for beginners, but widely regarded as the classic C programming book.
最后,如果你想买一本权威参考书,请认准《C程序设计语言》(The C Programming Language)。这本书非常简练,不适合新手,但是被广泛认为是一部经典。