Mastering C Pointers (2nd Edition) cover

Mastering C Pointers (2nd Edition)

Rating 4.2
Chapters
8
Series
Turing Programming Series
ISBN
9787115554895

Tags

Summary

Mastering C Pointers (2nd Edition) is a technical book devoted entirely to C pointers, written by Japanese programmer Kazuya Maebashi and translated into Chinese by Zhu Wenjia; it belongs to the Turing Programming Series. The book addresses a single topic—pointers—yet covers the points where learning them most often stalls. It begins with the basic model of memory and addresses, using small runnable experiments to let readers see for themselves how function calls, static variables, automatic variables (the stack), malloc dynamic allocation (the heap), alignment, and byte order are actually laid out in memory. It then uses this to unravel the relationship between pointers and arrays—"seemingly similar, fundamentally different"—and the rules of the address operator, indirection operator, subscript operator, and pointer arithmetic. Next it systematically explains how to parse the convoluted C declaration syntax and clarifies complex types such as function pointers and pointers to arrays. Finally it turns to practical application, using cases such as counting word frequencies and a drawing tool's data structures to demonstrate pointers in structures like linked lists, and summarizes common pitfalls and idiomatic patterns. The second edition substantially revises the memory layout content for 64-bit operating systems and adds coverage of variable-length arrays and other features under ISO C99 and C11. It is aimed at intermediate learners with existing C knowledge and computer science students, and can serve as a C course reference.

Editor's review

市面上讲C语言的书很多,专门讲指针还讲得这么细的很少。这本书的优点在于“不空谈”:作者前桥和弥是日本一线程序员,习惯用实验说话——写一段小程序、打印一组地址,让读者自己看见栈、堆、静态区里变量的位置,指针那些抽象的规则于是有了具体的落点。第2版基于64位环境重写了内存相关的部分,并补入C99、C11的内容,不会出现照着老书实验、结果地址宽度对不上的尴尬。作者的“毒舌”文风也值得一提:对C语言语法的不完备之处直言不讳,读起来不闷,还能顺带纠正不少从教材里带出来的误解。全书篇幅不算大,却做到了从概念到数据结构案例的贯通,适合当作“指针专题”的第二本书——先有一本入门教材打底,再拿它把指针彻底理清。

Who it's for

A good fit for

  • 学完C语言基础语法、被指针卡住的中级学习者
  • 计算机专业在读学生,需要补充指针与内存模型的系统认识
  • 从事嵌入式、驱动、底层开发的工程师,想理清内存布局细节
  • 想读懂复杂C声明、函数指针和数据结构用法的自学者

Not a good fit for

  • 完全没有C语言基础的零起点读者,建议先读一本入门教材
  • 只想快速查阅语法条目、不需要理解底层模型的人

Reading tips

  1. 先完成第2章的内存实验,跟着敲代码并打印地址,把栈、堆、静态区的概念落到实际观察上。
  2. 第3章讲声明解读与表达式时慢读,可对照自己项目中的复杂声明逐条练习,做过一遍比反复看更有效。
  3. 读完后把书中数据结构案例改写一遍,例如用链表实现单词统计,检验是否真正掌握了指针操作。

About the publisher

Posts & Telecom Press China · Founded in 1953

Posts & Telecom Press is known for its strengths in science and technology, computing, and information and communications titles, and has extended its publishing into photography, art, software learning, and inspirational growth, giving it a fairly diverse range. Its catalog includes computing and communications works such as Refactoring and Patterns (Revised Edition) and Huawei Switch Learning Guide (Second Edition), alongside bilingual collector's editions such as The Little Prince (Chinese-English-French illustrated collector's edition), The Great Gatsby, and Three Days to See. Beijing Ten Years: 1980-1990 and Ghost Blade: WLOP Personal Illustration Collection reflect its presence in photography and art. Its authors include Antoine de Saint-Exupéry, Helen Keller, Joshua Kerievsky, Wang Da, Zhang Zhaozeng, and WLOP.

Contents

  1. Chapter 0 Goals and Intended Readers
  2. Chapter 1 Laying the Foundation—Preliminaries and Review (What Kind of Language C Is; Memory and Addresses; About Pointers; About Arrays)
  3. Chapter 2 An Experiment—How C Uses Memory (Virtual Addresses; How Memory Is Used; Functions and String Literals; Static Variables; Automatic Variables and the Stack; Recursive Calls; Variable-Length Arrays in C99; malloc() Dynamic Allocation; Alignment; Byte Order)
  4. Chapter 3 Demystifying the Syntax—What Is Really Going On (Parsing C Declarations; The Data Type Model; Expressions; Arrays and Pointers Are Fundamentally Different)
  5. Chapter 4 Common Uses of Arrays and Pointers (Basic Usage; Combined Use)
  6. Chapter 5 Data Structures—The Real Use of Pointers (Case Study 1: Counting Word Frequencies; Case Study 2: Data Structures for a Drawing Tool)
  7. Chapter 6 Miscellaneous—Odds and Ends (New Function Groups; Pitfalls; Idiomatic Patterns)
  8. References

FAQ

这本书适合C语言零基础的人读吗?
不太适合。作者在前言中就把读者对象定位为已有C语言基础的中级学习者,书中会直接使用函数、结构体、数组等概念,零基础读者容易跟不上,建议先读完一本入门教材再来。
第1版(2013年,吴雅明译)和第2版有什么区别?
第2版由朱文佳翻译,基于64位操作系统对内存布局、动态分配等内容做了大幅修订,并新增ISO C99、C11标准(如可变长数组)的介绍;第1版为32位环境下的内容,部分实验结论在新机器上会不一致。
书中的代码需要什么环境才能运行?
书中示例以标准C为主,可在GCC、Clang等常见编译器上编译运行;出版社提供配套代码资源下载,建议对照版权页或图灵社区页面获取。
读完这本书能达到什么水平?
能够独立解读复杂C声明、理解指针与数组的本质差别,掌握栈、堆、对齐、字节序等内存机制,并用指针实现链表等数据结构;但C语言标准库与工程实践仍需其他书籍补充。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category