C Traps and Pitfalls
暫譯: C 語言的陷阱與誤區
Andrew Koenig
- 出版商: Addison Wesley
- 出版日期: 1989-01-11
- 售價: $1,880
- 貴賓價: 9.5 折 $1,786
- 語言: 英文
- 頁數: 160
- 裝訂: Paperback
- ISBN: 0201179288
- ISBN-13: 9780201179286
-
相關分類:
C 程式語言
已絕版
買這商品的人也買了...
-
$1,190$1,131 -
$600$588 -
$590$466 -
$980$960 -
$290$247 -
$780$616 -
$990$782 -
$2,550$2,423 -
$480$408 -
$820$648 -
$680$646 -
$880$695 -
$1,127Database System Concepts, 5/e (IE) (美國版ISBN:0072958863)
-
$540$427 -
$390$308 -
$650$507 -
$680$537 -
$550$435 -
$680$666 -
$600$540 -
$1,100$1,078 -
$299$236 -
$880$695 -
$1,200$1,020 -
$520$411
商品描述
Description:
Even C experts come across problems that require days ofdebugging to fix. This book helps to prevent such problems byshowing how C programmers get themselves into trouble. Each ofthe book's many examples has trapped a professional programmer.
In addition to its examples, C Traps and Pitfalls offers adviceon:
- avoiding off-by-one errors
- understanding and constructing function declarations
- understanding the subtle relationship between pointers andarrays
Distilled from the author's experience over a decade ofprogramming in C, this book is an ideal resource for anyone,novice or expert, who has ever written a C program.
Table of Contents:
Introduction.
1. Lexical Pitfalls.
= is not ==
& and | are not && or ||
Greedy lexical analysis.
Integer constants.
Strings and characters.
2. Syntactic pitfalls.
Understanding function declarations.
Operators don't always have the precedence you want.
Watch those semicolons!
The switch statement.
Calling functions.
The dangling else problem.
3. Semantic pitfalls.
Pointers and arrays.
Pointers are not arrays.
Array declarations as parameters.
Eschew synecdoche.
Null pointers are not null strings.
Counting and asymmetric bounds.
Order of evaluation.
The &&, ||, and ! operators.
Integer overflow.
Returning a value from main.
4. Linkage.
What is a linker?
Declarations vs. definitions.
Name conflicts and the static modifier.
Arguments, parameters, and return values.
Checking external types.
Header files.
5. Library functions.
Getchar returns an integer.
Updating a sequential file.
Buffered output and memory allocation.
Using errno for error detection.
The signal function.
6. The preprocessor.
Spaces matter in macro definitions.
Macros are not functions.
Macros are not statements.
Macros are not type definitions.
7. Portability pitfalls.
Coping with change.
What's in a name?
How big is an integer?
Are characters signed or unsigned?
Shift operators.
Memory location zero.
How does division truncate?
How big is a random number?
Case conversion.
Free first, then reallocate?
An example of portability problems.
8. Advice and answers.
Advice.
Answers.
Appendix: printf, varargs, and stdarg.
The printf family.
Simple format types.
Modifiers.
Flags.
Variable field width and precision.
Neologisms.
Anachronisms.
Variable argument lists with varargs.h.
Implementing varargs.h.
商品描述(中文翻譯)
描述:
即使是 C 語言專家也會遇到需要數天除錯才能解決的問題。本書通過展示 C 程式設計師如何陷入麻煩來幫助防止此類問題。本書中的每個例子都曾讓專業程式設計師陷入困境。
除了例子之外,《C 語言陷阱與誤區》還提供了以下建議:
- 避免 off-by-one 錯誤
- 理解和構造函數聲明
- 理解指標與陣列之間的微妙關係
本書提煉自作者十多年 C 語言程式設計的經驗,對於任何曾經編寫過 C 程式的初學者或專家來說,都是理想的資源。
目錄:
引言。
1. 詞法誤區。
= 不是 ==
& 和 | 不是 && 或 ||
貪婪的詞法分析。
整數常數。
字串和字符。
2. 語法誤區。
理解函數聲明。
運算子不一定具有你想要的優先順序。
注意那些分號!
switch 語句。
呼叫函數。
懸空的 else 問題。
3. 語意誤區。
指標和陣列。
指標不是陣列。
陣列聲明作為參數。
避免提喻。
空指標不是空字串。
計數和不對稱邊界。
評估順序。
&&、|| 和 ! 運算子。
整數溢位。
從 main 返回值。
4. 連結。
什麼是連結器?
聲明與定義。
名稱衝突和 static 修飾符。
參數、參數和返回值。
檢查外部類型。
標頭檔案。
5. 函數庫。
getchar 返回整數。
更新順序檔案。
緩衝輸出和記憶體分配。
使用 errno 進行錯誤檢測。
signal 函數。
6. 預處理器。
宏定義中的空格很重要。
宏不是函數。
宏不是語句。
宏不是類型定義。
7. 可攜性誤區。
應對變化。
名稱中有什麼?
整數有多大?
字符是有符號還是無符號?
位移運算子。
記憶體位置零。
除法如何截斷?
隨機數有多大?
大小寫轉換。
先釋放,再重新分配?
可攜性問題的例子。
8. 建議與答案。
建議。
答案。
附錄:printf、varargs 和 stdarg。
printf 家族。
簡單格式類型。
修飾符。
標誌。
可變欄位寬度和精度。
新詞。
時代錯誤。
使用 varargs.h 的可變參數列表。
實現 varargs.h。