雙語版C程式設計(第2版)

雙語版C程式設計(第2版)

《雙語版C程式設計(第2版)》是2017年2月電子工業出版社出版的圖書,作者是Paul Kelly。

內容簡介

《語版C程式設計(第2版)》這本書由在電腦程式設計方面有著豐富教學和實踐經驗的中外作者合作編寫。共14章內容,由淺入深全面介紹C程式設計方法,包括基本數據類型和基本輸出輸出方式、各種控制結構和語句、指針和數組、字元串、函式、結構、檔案輸入和輸出等內容,最後討論了C預處理器。

本書由在電腦程式設計方面有著豐富教學和實踐經驗的中外作者合作編寫。共14章內容,由淺入深全面介紹C程式設計方法,包括基本數據類型和基本輸出輸出方式、各種控制結構和語句、指針和數組、字元串、函式、結構、檔案輸入和輸出等內容,最後討論了C預處理器。

本書所有實例經過精心挑選、貼近生活,尤其強調讀者的親自參與意識。每章都為初學者提供了常見錯誤分析,所選習題可提高讀者上機編程的興趣。本書採用中英文對照混排,既方便初學者熟悉相關概念和內容,也便於英文非母語的讀者熟悉英文專業辭彙。

目錄

Chapter One Introduction to C(引言) 1

1.1 Brief history of C(C 語言簡史) 1

1.2 Why programmers use C(為什麼程式設計師愛用C語言) 1

1.2.1 C is portable 1

1.2.2 C is a structured programming language 2

1.2.3 C is efficient 2

1.2.4 C is flexible 2

1.2.5 C is powerful 2

1.2.6 C is concise 3

1.3 Developing a C program(開發C 程式) 3

1.4 Suggestions for learning C programming(學習C 語言程式設計的建議) 4

Chapter Two C Data Types(C數據類型) 6

2.1 Constants(常量) 6

2.2 Variables(變數) 6

2.3 Simple output to the screen(簡單的螢幕輸出) 8

2.4 Comments(注釋) 9

2.5 Data types(數據類型) 10

2.5.1 Short integer data types 10

2.5.2 Long integer data types 11

2.5.3 Unsigned integer data types 11

2.5.4 Double floating-point data type 11

2.6 Data type sizes(數據類型的大小) 11

Programming pitfalls 13

Quick syntax reference 13

Exercises 14

Chapter Three Simple Arithmetic Operations and Expressions(簡單的算術運算和表達式) 16

3.1 C operators(C 運算符) 16

3.1.1 The assignment operator 16

3.1.2 Arithmetic operators 17

3.1.3 Increment and decrement operators 19

3.1.4 Combined operators 21

3.2 Operator precedence(運算符優先權) 22

3.3 Type conversions and casts(類型轉換與強制類型轉換) 24

Programming pitfalls 26

Quick syntax reference 27

Exercises 27

Chapter Four Keyboard Input and Screen Output(鍵盤輸入和螢幕輸出) 30

4.1 Simple keyboard input(簡單的鍵盤輸入) 30

4.2 Using a width and precision specification in printf()

[在函式printf( )中使用域寬和精度說明] 31

4.3 Single-character input and output(單個字元的輸入和輸出) 33

Programming pitfalls 35

Quick syntax reference 35

Exercises 36

Chapter Five Control Statements: if and switch(控制語句:if 和switch) 38

5.1 The if statement(if 語句) 38

5.2 The if-else statement(if-else 語句) 39

5.3 Logical operators(邏輯運算符) 41

5.4 Nested if statements(嵌套的if 語句) 42

5.5 The switch statement(switch 語句) 44

5.6 The conditional operator ?:(條件運算符) 46

Programming pitfalls 47

Quick syntax reference 48

Exercises 48

Chapter Six Iterative Control Statements: while, do-while, and for

(循環控制語句:while、do-while和for) 51

6.1 The while statement(while 語句) 51

6.2 The do-while loop(do-while 循環) 52

6.3 The for statement(for 語句) 54

6.4 Nested loops(嵌套的循環) 56

Programming pitfalls 58

Quick syntax reference 59

Exercises 59

Chapter Seven Arrays(數組) 61

7.1 Introduction to arrays(引言) 61

7.2 Initialising arrays(數組初始化) 66

7.3 Two-dimensional arrays(二維數組) 67

7.4 Initialising two-dimensional arrays(二維數組的初始化) 68

7.5 Multi-dimensional arrays(多維數組) 69

Programming pitfalls 70

Quick syntax reference 70

Exercises 70

Chapter Eight Pointers(指針) 73

8.1 Variable addresses(變數的地址) 73

8.2 Pointer variables(指針變數) 74

8.3 The dereference operator *(解引用運算符*) 75

8.4 Why use pointers? (為什麼使用指針) 76

Programming pitfalls 77

Quick syntax reference 77

Exercises 77

Chapter Nine Pointers and Arrays(指針和數組) 79

9.1 Pointers and one-dimensional arrays(指針和一維數組) 79

9.2 Pointers and multi-dimensional arrays(指針和多維數組) 81

9.3 Dynamic memory allocation(動態記憶體分配) 82

9.3.1 The malloc() function 82

9.3.2 The calloc() function 85

9.3.3 The realloc() function 86

9.3.4 Allocating memory for multi-dimensional arrays 87

Programming pitfalls 90

Quick syntax reference 90

Exercises 90

Chapter Ten Strings(字元串) 93

10.1 String literals(字元串) 93

10.2 Long character strings(長字元串) 94

10.3 Strings and arrays(字元串和數組) 94

10.4 Displaying a string(顯示一個字元串) 95

10.5 The puts() function[puts( )函式] 97

10.6 The gets() function[gets( )函式] 98

10.7 Accessing individual characters of a string(訪問字元串中的單個字元) 99

10.8 Assigning a string to a pointer (用字元串為字元指針賦值) 100

10.9 String functions(字元串處理函式) 101

10.9.1 Finding the length of a string 101

10.9.2 Copying a string 102

10.9.3 String concatenation 102

10.9.4 Comparing strings 102

10.9.5 Other string functions 103

10.10 Converting numeric strings to numbers (數值字元串向數值的轉換) 103

10.11 Arrays of strings(字元串數組) 105

Programming pitfalls 108

Quick syntax reference 109

Exercises 109

Chapter Eleven Functions(函式) 112

11.1 Introduction(引言) 112

11.2 Function arguments(函式參數) 114

11.3 Returning a value from a function (從函式返回一個值) 116

11.4 Passing arguments by value (按值傳參) 118

11.5 Passing arguments by reference(按引用傳參) 119

11.6 Changing arguments in a function (在函式中改變實參的值) 120

11.7 Passing a one-dimensional array to a function (向函式傳遞一維數組) 121

11.8 Passing a multi-dimensional array to a function (向函式傳遞多維數組) 123

11.9 Storage classes(變數的存儲類型) 124

11.9.1 auto 124

11.9.2 static 125

11.9.3 extern 126

11.9.4 register 128

11.10 Command line arguments (命令行參數) 128

11.11 Mathematical functions(數學函式) 130

11.11.1 Some commonly used trigonometric functions 130

11.11.2 Other common mathematical functions 131

11.11.3 Pseudo-random number functions 132

11.11.4 Some time-related functions 132

11.12 Recursion 133

Programming pitfalls 136

Quick syntax reference 137

Exercises 137

Chapter Twelve Structures(結構體) 141

12.1 Defining a structure(定義結構體) 141

12.2 Pointers to structures(結構體指針) 144

12.3 Initialising a structure variable (結構體變數的初始化) 145

12.4 Passing a structure to a function (向函式傳遞結構體變數) 147

12.5 Nested structures(嵌套的結構體) 149

12.6 Including a structure template from a file (從檔案中引用結構體模板) 150

12.7 The typedef statement (typedef 語句) 151

12.8 Arrays of structures(結構體數組) 152

12.9 Enumerated data types(枚舉數據類型) 158

Programming pitfalls 160

Quick syntax reference 161

Exercises 162

Chapter Thirteen File Input and Output(檔案的輸入和輸出) 165

13.1 Binary and ASCII (text) files [二進制檔案和ASCII(文本)檔案] 165

13.2 Opening and closing files (檔案的打開和關閉) 166

13.3 Reading a character from a file using fgetc()

[使用函式fgetc( )從檔案中讀字元] 168

13.4 Writing a character to a file using fputc()

[使用函式fputc( )向檔案中寫字元] 170

13.5 Reading a string of characters from a file using fgets()

[使用函式fgets( )從檔案中讀字元串] 171

13.6 Writing a string of characters to a file using fputs()

使用函式fputs( )向檔案中寫字元串] 172

13.7 Formatted input-output to a file using fscanf() and fprintf() 173

[使用函式fscanf( )和fprintf( )進行檔案的格式化讀寫] 173

13.8 The standard files(標準檔案) 174

13.9 Block input-output using fread() and fwrite() 175

[使用函式fread( )和fwrite( )進行塊讀寫] 175

13.10 Rewinding a file using rewind()[使用函式rewind( )對檔案重定位] 177

13.11 Random access of files using fseek() [使用函式fseek( )隨機訪問檔案] 179

13.12 Finding the position in a file using ftell()

[使用函式ftell( )查找檔案的當前位置] 184

13.13 Deleting a file using remove()[使用函式remove( )刪除檔案] 184

Programming pitfalls 185

Quick syntax reference 186

Exercises 187

Chapter Fourteen The C Preprocessor(C編譯預處理) 190

14.1 Including files(包含檔案) 190

14.2 Defining macros(定義宏) 191

14.3 Macro parameters(帶參數的宏) 192

14.4 Macros and functions(宏和函式) 194

14.5 Some useful macros(一些有用的宏) 195

14.6 Conditional directives(條件編譯預處理指令) 195

14.7 Character-testing macros(字元檢測宏) 196

14.8 The assert() macro [assert() 宏] 197

Programming pitfalls 200

Quick syntax reference 200

Exercises 200

Appendix A List of C Keywords 202

Appendix B Precedence and Associativity of C Operators 203

Appendix C ASCII Character Codes 205

Appendix D Fundamental C Built-in Data Types 207

熱門詞條

聯絡我們