Digital Library

C和指针 (里科)(Z-Library)

里科

C和指针 (里科)(Z-Library)

Author 里科

c/c++/c#
Language English

本书共18章,覆盖了数据,语句,操作符和表达式,指针,函数,数组,字符串,结构和联合等几乎所有重要的C编程话题.书中给出了很多编程技巧和提示,每章后面有针对性很强的练习,附录部分则给出了部分练习的解答.

Format EPUB
Size 6.4 MB
164
Views
0
Downloads
0.00
Total Donations

AI Guide

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

Full assistant
AI guide
# C和指针 (Pointers on C) — Reading Guide ## 【One-Line Pitch】 A classic, mentor-style C programming textbook that weaves pointers—the language's most powerful and dangerous feature—through every major topic, from data types and functions to arrays, strings, structures, and dynamic memory, teaching both the mechanics and the hard-won idioms of professional C practice. Ideal for programmers with some experience in another language who want to master C properly, and for C programmers seeking to deepen their understanding of pointers and efficiency trade-offs. --- ## 【Book Arc】 - **Opening (~0%–13%)**: The book opens with a rationale for why C still matters (efficiency, control, portability, and its role as the foundation of C++) and why pointers specifically deserve a book-length treatment. The author positions the book as a tutorial for readers with prior programming experience, not a first programming text, and explains the book's organization, typographic conventions, and the "warning" and "tip" markers used throughout. - **Early (~13%–23%)**: A complete worked example—a column-rearranging program—introduces the entire language surface quickly: comments, preprocessor directives, `main`, functions, loops, arrays, strings, `printf`/`scanf`, and the crucial fact that array names decay to pointers when passed to functions. This chapter deliberately front-loads enough to write simple programs, with promises of deeper treatment later. - **Early–Middle (~23%–48%)**: The book transitions into systematic fundamentals: the translation and execution environments, lexical rules, program style, and then a deep dive into data (integer and floating-point families, declarations, `typedef`, constants, scope, linkage attributes, and storage classes). Statements (all control flow), operators and expressions (including precedence, type conversions, and evaluation order), and the first full chapter on pointers (memory addresses, indirect access, NULL, pointer arithmetic, and pointer expressions) follow in sequence. - **Middle (~48%–65%)**: Functions receive thorough treatment—definitions, prototypes, parameters, recursion versus iteration, and variable-length argument lists via `stdarg` macros—followed by arrays (one- and multi-dimensional, the relationship between arrays and pointers, and array parameters) and then strings, characters, and bytes (the full `string.h` family, character classification, and memory operations). - **Late (~65%–85%)**: Structures and unions (declaration, access, self-reference, storage allocation, bit-fields, and variant records), dynamic memory allocation (`malloc`, `free`, `calloc`, `realloc`, and common errors), and the use of structures with pointers to build linked lists (singly and doubly linked, with insertion operations) form the practical data-structures core. - **Ending (~85%–100%)**: Advanced pointer topics—pointers to pointers, complex declarations, function pointers (callbacks and transfer tables), command-line arguments, and string constants—are followed by the preprocessor (`#define`, macros versus functions, conditional compilation, file inclusion), then standard I/O (streams, formatted and binary I/O, buffering, and error handling), and finally the standard library (integer functions, random numbers, string conversion, and more). --- ## 【Key Takeaways】 - **Pointers are the thread that ties C together** (Early): Unlike books that treat pointers as a single isolated chapter, this book introduces them early and revisits them in every context—arrays, functions, strings, structures, and dynamic memory—because mastery of pointers is the prerequisite for writing effective C. The author's core argument is that pointers are what make C powerful, but also what make it dangerous. - **C's efficiency comes from the absence of a safety net** (Early): C does not check array subscripts or pointer validity, which saves time but shifts responsibility to the programmer. The book's recurring warning markers highlight exactly where beginners (and sometimes experts) make mistakes, such as forgetting the `&` operator in `scanf` or assuming bounds checking exists. - **Array names decay to pointers when passed to functions** (Early): When an array is passed as an argument, what is actually passed is a pointer to its first element, giving call-by-reference semantics. This is why array parameters don't specify length, why the length must be passed separately, and why `const` on array parameters is valuable—it lets the compiler enforce the function author's intent not to modify the caller's data. - **The `while ((ch = getchar()) != EOF && ch != '\n')` idiom is a canonical C pattern** (Early): This loop, with an empty body, shows how C programmers combine assignment, comparison, and short-circuit evaluation in a single expression. The book explains why `ch` must be an `int` (to hold `EOF`), why the empty statement is legitimate, and why readability concerns yield to the maintenance benefits of a well-known idiom. - **Strings are just NUL-terminated character arrays** (Early): C has no string type; a string is a convention—a sequence of characters ending in a NUL byte. This explains why `strcpy`, `strcat`, and friends require the programmer to ensure destination capacity, why `gets` is dangerous (it cannot prevent overflow), and why the book recommends `fgets` instead. - **Recursion and iteration are both tools, with trade-offs** (Middle): The book covers recursion in depth, including how to trace recursive functions and when recursion is preferable to iteration. The treatment is practical, focusing on when each approach is clearer or more efficient rather than dogmatic preference. - **Dynamic memory management is a discipline, not just an API** (Late): `malloc`, `free`, `calloc`, and `realloc` are introduced alongside the common errors that plague C programmers—memory leaks, dangling pointers, and buffer overruns. The book emphasizes that using dynamically allocated memory correctly requires understanding both the mechanics and the pitfalls. - **Function pointers enable callbacks and transfer tables** (Late): Advanced pointer topics include using pointers to functions for callbacks (letting library code call user code) and transfer tables (replacing long switch statements with arrays of function pointers). These idioms are essential for writing flexible, maintainable C. --- ## 【Reading Tips】 - **Read Chapter 1 carefully even if you know some C**: The worked example (the `rearrange` program) is not just a syntax tour—it introduces the book's philosophy, the warning/tip conventions, and key idioms (like the empty-body `while` loop and `const` array parameters) that recur throughout. Skim it only if you're already comfortable with pointers and arrays. - **Deep-read the pointer chapters (6, 8, and 13)**: These are the heart of the book. Chapter 6 builds the mental model of memory and addresses; Chapter 8 clarifies the array-pointer relationship; Chapter 13 covers advanced declarations and function pointers. If you're short on time, prioritize these over the more reference-like chapters (15 and 16 on I/O and the standard library). - **Treat the "warning" boxes as a checklist**: The author explicitly marks common beginner errors. Before writing production code, scan the warning summaries at the end of each chapter—they condense decades of C programming mistakes into a quick review list. - **Do the starred exercises**: The book includes programming exercises rated by difficulty (★ to ★★★★★), with selected answers in the appendix. The exercises are not busywork; many have been used as classroom tests for years and will expose gaps in your understanding that reading alone won't reveal. - **Skim Chapters 15–16 (I/O and standard library) as

Passage locations

Excerpt 1
数组名 8.2.3 下标 8.2.4 指向数组的指针 8.2.5 作为函数参数的多维数组 8.2.6 初始化 8.2.7 数组长度自动计算 8.3 指针数组 8.4 总结 8.5 警告的总结 8.6 编程提示的总结 8.7 问题 8.8 编程练习 第9章 字符串、字符和字节 9.1 字符串基础 9.2 字符串长度...
View in text
Excerpt 2
s.rit.edu/~kar/)。这个站点包含本书所有程序的源代码,以章为单位分类。你还可以在上面看到本书的最新勘误表。你还可以联系附近的Addison Wesley Longman代表,获取 Instructor’s Guide ,它包含了书上未给出答案的问题和编程练习的所有答案。 如果你是一位教育工作者,也可...
View in text
Excerpt 3
数中,并未指定数组的长度。这种格式是正确的,因为不论调用函数的程序传递给它的数组参数的长度是多少,这个函数都将照收不误。这是一个伟大的特性,它允许单个函数操纵任意长度的一维数组。这个特性不利的一面是函数没法知道该数组的长度。如果确实需要数组的长度,它的值必须作为一个单独的参数传递给函数。 当本例的read_col...
View in text
Excerpt 4
程序必须有一个main函数,它是程序执行的起点。函数的标量参数通过传值的方式进行传递,而数组名参数则具有传址调用的语义。字符串是一串由NUL字节结尾的字符,并且有一组库函数以不同的方式专门用于操纵字符串。printf函数执行格式化输出,scanf函数用于格式化输入,getchar和putchar分别执行非格式化字...
View in text

Support Author

0.00
Total Amount (¥)
0
Donation Count
Please enter an amount Minimum ¥1

You will be redirected to Alipay to complete payment, then return here.

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List