C语言程序设计(双语版) / “十四五”普通高等院校计算机类专业系列教材
¥59.80定价
作者: 赵小蕾,许喜斌,耿江涛
出版时间:2024-10
出版社:中国铁道出版社
- 中国铁道出版社
- 9787113313418
- 1版
- 531481
- 大16开
- 2024-10
- 文理通用
- 本科 高职
作者简介
内容简介
本书是“十四五”普通高等院校计算机类专业系列教材之一,从基础语法到高级应用深入剖析了C语言程序设计的核心知识与实用技巧,详细解读了C语言的基本概念、数据类型、运算符、控制结构、数组、指针、函数、结构体和文件操作等关键内容,并通过实际案例让读者深入理解C语言的编程精髓。
本书系统性强,逻辑严谨,实例丰富,采用循序渐进的方式让读者逐步掌握相关知识,强化编程能力。书中对重点、难点进行了详细解析,并配有丰富的电子教学资源,提供一站式C语言学习体验,引领读者轻松开启编程之旅。中英文对照的编写方式有助于学生提升英语能力,熟悉专业词汇。
本书适合作为普通高等院校软件工程、计算机科学与技术、数字媒体技术、电子信息科学与技术、电气工程及其自动化、智能制造工程、人工智能、大数据等专业平台课程“C语言程序设计”教材,也可作为编程爱好者的参考书。
本书系统性强,逻辑严谨,实例丰富,采用循序渐进的方式让读者逐步掌握相关知识,强化编程能力。书中对重点、难点进行了详细解析,并配有丰富的电子教学资源,提供一站式C语言学习体验,引领读者轻松开启编程之旅。中英文对照的编写方式有助于学生提升英语能力,熟悉专业词汇。
本书适合作为普通高等院校软件工程、计算机科学与技术、数字媒体技术、电子信息科学与技术、电气工程及其自动化、智能制造工程、人工智能、大数据等专业平台课程“C语言程序设计”教材,也可作为编程爱好者的参考书。
目录
Chapter 1
第 1 章
First Introduction to C Programming and Algorithms 1
初识 C 程序设计与算法
1.1 Introduction to C (C 语言的引入) ............................................................................................. 2
1.1.1 What Is a Computer Language(什么是计算机语言) ......................................................2
1.1.2 Why to Learn C Language (为什么学习 C 语言) ...........................................................4
1.1.3 How to Learn C Language Well (怎样学好 C 语言) .......................................................6
1.2 First Look at C Programming (初识 C 程序设计) .................................................................. 7
1.2.1 C Standards (C 标准) .......................................................................................................7
1.2.2 Structure and Execution of C Program (C 程序结构及运行) .........................................9
1.2.3 Programming Tasks (程序设计的任务) .........................................................................11
1.3 C Environment Installation and Running (C 环境安装与运行) .......................................... 12
1.3.1 Installation and Startup of RedPanda C++ (小熊猫 C++ 的安装与启动) ....................12
1.3.2 RedPanda C++ Tutorial (小熊猫 C++ 的使用) .............................................................14
1.4 Defi nition, Characteristics, and Representation of Algorithms
(算法定义、特性及表示) .......................................................................................................... 16
1.4.1 What Is an Algorithm(什么是算法) ...............................................................................16
1.4.2 Features of Algorithms (算法的特性) ............................................................................17
1.4.3 Representation Methods of Algorithms(算法的表示) ...................................................17
Summary (小结) ...................................................................................................................................22
Exercise (习题) .....................................................................................................................................23
Chapter 2
第2章
Sequential Programming 25
顺序程序设计
2.1 Sequential Programming Examples and Program Components
(顺序程序设计举例及程序组成成分) ....................................................................................... 25
2.1.1 Sequential Programming Example (顺序程序设计举例) .............................................26
2.1.2 Program Components(程序组成成分)...........................................................................27
2.2 Basic Data Types (基本数据类型) ......................................................................................... 27
2.2.1 Why Data Types Are Necessary(为什么需要数据类型) ...............................................28
2.2.2 Basic Data Types(基本数据类型 ) .................................................................................28
2.3 Constants and Variables(常量与变量) .................................................................................. 30
2.3.1 Constants (常量) .............................................................................................................31
C 语言程序设计(双语版) II
2.3.2 Variables (变量) ............................................................................................................. 32
2.3.3 Symbolic Constants (符号常量) ................................................................................... 33
2.4 C Operators and Expressions(C 运算符及表达式) .............................................................35
2.4.1 Operator Overview (运算符概述) ................................................................................. 35
2.4.2 Common Operators and Expressions (常用运算符及表达式) ..................................... 35
2.4.3 Type Conversions and Casts (类型转换) ...................................................................... 38
2.5 C Statements(C 语句) .............................................................................................................39
2.5.1 What Are C Statements(什么是 C 语句) ...................................................................... 40
2.5.2 Output Statements (输出语句) ...................................................................................... 41
2.5.3 Input Statements (输入语句)......................................................................................... 43
2.5.4 Single-character Input and Output (单个字符的输入和输出) ..................................... 45
2.6 Comprehensive Cases(综合案例) .........................................................................................47
Summary (小结) .................................................................................................................................. 49
Exercise (习题) .................................................................................................................................... 50
Chapter 3
第3章
Selective Structure Programming 52
选择结构程序设计
3.1 Relational, Logical Operators and Expressions
(关系、逻辑运算符及其表达式) ...............................................................................................52
3.1.1 Why Do We Need Selection Structures(为什么需要选择结构) .................................. 53
3.1.2 Relational Operators and Expressions(关系运算符及其表达式) ................................ 53
3.1.3 Logical Operators and Expressions (逻辑运算符及其表达式) ................................... 54
3.2 Selection Structures Using if and switch Statements
(if 和 switch 语句实现选择结构) ...............................................................................................57
3.2.1 Selection Structures Using if Statements(if 语句实现选择结构) ................................ 57
3.2.2 Using the switch Statement for Multi-branch Selection Structures
(switch 语句实现多分支选择结构) ............................................................................... 64
3.3 Comprehensive Cases(综合案例) .........................................................................................66
Summary (小结) .................................................................................................................................. 71
Exercise (习题) .................................................................................................................................... 72
Chapter 4
第4章
Loop Structure Programming 75
循环结构程序设计
4.1 Why Do We Need a Loop Structure(为什么需要循环结构) ...............................................75
4.2 The While and do...while Statements(while 和 do...while 语句) .......................................77
4.2.1 The While Statements(while 语句) ............................................................................... 77
CONTENTS
目 录 III
4.2.2 The do...while Statement(do...while 语句) .................................................................... 79
4.2.3 Comparison of while and do...while(while 和 do...while 的比较) ............................... 81
4.3 The for Statements (for 语句) ................................................................................................83
4.3.1 Review and Introduction (回顾与引入) ........................................................................ 83
4.3.2 The for Statements to Implement Loops (for 语句实现循环) ...................................... 84
4.3.3 Special Forms of the for Statement (for 语句的特殊形式) .......................................... 87
4.3.4 Comparison of Three Loop Statements (三种循环语句的比较) ................................. 89
4.4 Loop Control Statements(循环控制语句) .............................................................................90
4.4.1 The break Statement(break 语句) .................................................................................. 90
4.4.2 The continue Statement(continue 语句) ........................................................................ 93
4.4.3 Difference Between break and continue(break 和 continue 的区别) ........................... 94
4.5 Nesting of Loops(循环的嵌套) ...............................................................................................95
4.5.1 What Is Nesting of Loops (什么是循环的嵌套) .......................................................... 95
4.5.2 Examples of Loop Nesting (循环嵌套的举例)............................................................. 97
4.6 Comprehensive Cases(综合案例) ...................................................................................... 102
Summary (小结) ................................................................................................................................ 107
Exercise (习题) .................................................................................................................................. 107
Chapter 5
第5章
Batch Processing of Data Using Arrays 110
利用数组批量处理数据
5.1 Definition and Use of One-dimensional Array ( 一维数组的定义和使用 ) ..........................110
5.1.1 Source of Array (数组的来源) .................................................................................... 110
5.1.2 Definition of One-dimensional Array (一维数组的定义) .......................................... 112
5.1.3 Storage of One-dimensional Array (一维数组的存储) .............................................. 112
5.1.4 Reference of One-dimensional Array (一维数组的引用) .......................................... 113
5.1.5 Initialization of One-dimensional Array (一维数组的初始化) .................................. 114
5.2 Two-dimensional Array(二维数组) .......................................................................................116
5.2.1 Definition and Storage Mode of Two-dimensional Array
(二维数组定义及存储方式) ........................................................................................ 116
5.2.2 Reference of Two-dimensional Array (二维数组的引用) .......................................... 117
5.2.3 Initialization of Two-dimensional Array (二维数组的初始化) .................................. 118
5.2.4 Application Example of Two-dimensional Array (二维数组应用举例) .................... 119
5.3 Character Arrays and Strings(字符数组及字符串) ........................................................... 121
5.3.1 Character Array (字符数组) ........................................................................................ 121
5.3.2 String (字符串) ............................................................................................................ 122
5.3.3 String Handling Functions (字符串处理函数) ........................................................... 125
C 语言程序设计(双语版) IV
5.4 Comprehensive Cases(综合案例) ...................................................................................... 128
Summary (小结) ................................................................................................................................ 136
Exercise (习题) .................................................................................................................................. 136
Chapter 6
第6章
Pointer 139
指针
6.1 Pointers and Pointer Variables (指针和指针变量) ........................................................... 139
6.1.1 What Is a Pointer (什么是指针) .................................................................................. 140
6.1.2 Definition and Use of Pointer Variables (指针变量的定义与使用) ........................... 142
6.1.3 Precautions for Using Pointer Variable (指针变量使用注意事项) ............................ 145
6.2 Pointer Reference Array (指针引用数组) .......................................................................... 148
6.2.1 Pointer Variable Points to Array (指针变量指向数组)............................................... 148
6.2.2 Pointer Addition and Subtraction (指针加减运算) ..................................................... 149
6.2.3 Pointers Referencing Array Elements (指针引用数组元素) ...................................... 150
6.3 Pointer Reference String(指针引用字符串) ...................................................................... 153
6.3.1 Storage and Reference of Character Strings (字符串的存储与引用) ........................ 153
6.3.2 Character Array Reference String (字符数组引用字符串) ........................................ 154
6.3.3 Pointer Variable Reference String (指针变量引用字符串) ........................................ 155
6.3.4 Comparison of Character Array and Character Pointer Variable Reference
String Method (字符数组与字符指针变量引用字符串方法的比较) ...................... 157
6.4 Comprehensive Cases(综合案例) ...................................................................................... 158
Summary (小结) ................................................................................................................................ 163
Exercise (习题) .................................................................................................................................. 164
Chapter 7
第7章
Function 167
函数
7.1 Definition of Function (函数的定义) ................................................................................... 168
7.1.1 Why Use Functions (为什么要用函数) ...................................................................... 168
7.1.2 How to Define a Function (怎样定义函数) ................................................................ 170
7.2 Function Declaration and Call (函数的声明和调用) ......................................................... 174
7.2.1 What is Function Declaration and Call (什么是函数的声明和调用) ........................ 174
7.2.2 How Does the Function Work (函数如何工作) .......................................................... 177
7.3 Local and Global Variables (局部变量与全局变量) .......................................................... 178
7.3.1 Scope and Lifetime (作用域和生存期) ...................................................................... 178
7.3.2 Local Variables (局部变量) ......................................................................................... 178
7.3.3 Global Variables (全局变量) ....................................................................................... 180
CONTENTS
目 录 V
7.4 Storage of Variables (变量的存储方式) ............................................................................. 182
7.4.1 What Is the Storage of Variables (什么是变量的存储方式) ...................................... 182
7.4.2 Storage Categories of Local Variables (局部变量的存储类别) ................................. 183
7.4.3 Storage Categories of Global Variables (全局变量的存储类别) ............................... 186
7.5 Arrays as Function Parameters (数组作为函数参数) ...................................................... 188
7.5.1 Array Elements as Function Parameters (数组元素作为函数实参) .......................... 188
7.5.2 Arrays as Function Parameters (数组作为函数参数) ................................................ 190
7.6 Pointers as Function Parameters (指针作为函数参数) ................................................... 193
7.7 Application of Pointer in Function (指针在函数中的应用) ............................................... 198
7.7.1 Pointer to Function (指向函数的指针) ....................................................................... 199
7.7.2 Functions That Return Pointer Values (返回指针值的函数) ..................................... 205
7.8 Recursive Programming (递归程序设计) .......................................................................... 208
7.8.1 What is Recursion (什么是递归) ................................................................................ 208
7.8.2 How Does Recursion Work (递归如何工作) .............................................................. 209
7.8.3 How Is Recursion Designed (递归如何设计)............................................................. 211
7.9 Comprehensive Cases(综合案例) ...................................................................................... 213
Summary (小结) ................................................................................................................................ 218
Exercise (习题) .................................................................................................................................. 218
Chapter 8
第8章
Structures 223
结构体
8.1 Structure Type and Variable Definition(结构体的类型及变量定义) ............................... 224
8.1.1 Why Do We Need a Structure (为什么需要结构体) .................................................. 224
8.1.2 What Is a Structure (什么是结构体) ........................................................................... 225
8.1.3 Structure Variable (结构体变量) ................................................................................. 227
8.1.4 Storage Space Allocation of Structure Variable
(结构体变量的存储空间分配) .................................................................................... 228
8.1.5 Use of Structure Variables (结构体变量的使用)........................................................ 229
8.2 Structure Array and Structure Pointer (结构体数组及结构体指针) ............................... 232
8.2.1 Structure Array (结构体数组) ..................................................................................... 232
8.2.2 Structure Pointer (结构体指针) .................................................................................. 234
8.3 Dynamic Memory Allocation and Linked List Definition
(动态内存分配及链表定义) .................................................................................................... 235
8.3.1 Dynamic Memory Allocation (动态内存分配) .......................................................... 235
8.3.2 Linked List Definition (链表的定义) .......................................................................... 238
C 语言程序设计(双语版) VI
8.4 Creation and Output of Linked List(链表的创建和输出) ................................................. 239
8.4.1 Creation of Linked List (链表的创建) ........................................................................ 240
8.4.2 Output of Linked List (链表的输出)........................................................................... 243
8.5 Insertion, Search and Deletion of Dynamic Linked List
(动态链表的插入、查找和删除) ............................................................................................ 246
8.5.1 Insertion of Linked List (链表的插入) ....................................................................... 246
8.5.2 Search of Linked List (链表的查找) ........................................................................... 250
8.5.3 Deletion of Linked List (链表的删除) ........................................................................ 252
8.6 Comprehensive Cases(综合案例) ...................................................................................... 254
Summary (小结) ................................................................................................................................ 260
Exercise (习题) .................................................................................................................................. 260
Chapter 9
第9章
File 264
文件
9.1 File Open and Close (文件的打开与关闭) ......................................................................... 265
9.1.1 What Is a File (什么是文件) ....................................................................................... 265
9.1.2 Classification of Files (文件的分类) ........................................................................... 265
9.1.3 File Name (文件名) ..................................................................................................... 267
9.1.4 File Buffer (文件缓冲区) ............................................................................................ 267
9.1.5 File Open and Close Operations (文件的打开与关闭操作) ...................................... 269
9.2 File Read and Write Operations (文件的读写操作) ......................................................... 271
9.2.1 File Read and Write Functions (文件读写函数) ......................................................... 272
9.2.2 Application Examples (应用举例) .............................................................................. 273
9.3 Comprehensive Cases(综合案例) ...................................................................................... 278
Summary (小结) ................................................................................................................................ 286
Exercise (习题) .................................................................................................................................. 287
第 1 章
First Introduction to C Programming and Algorithms 1
初识 C 程序设计与算法
1.1 Introduction to C (C 语言的引入) ............................................................................................. 2
1.1.1 What Is a Computer Language(什么是计算机语言) ......................................................2
1.1.2 Why to Learn C Language (为什么学习 C 语言) ...........................................................4
1.1.3 How to Learn C Language Well (怎样学好 C 语言) .......................................................6
1.2 First Look at C Programming (初识 C 程序设计) .................................................................. 7
1.2.1 C Standards (C 标准) .......................................................................................................7
1.2.2 Structure and Execution of C Program (C 程序结构及运行) .........................................9
1.2.3 Programming Tasks (程序设计的任务) .........................................................................11
1.3 C Environment Installation and Running (C 环境安装与运行) .......................................... 12
1.3.1 Installation and Startup of RedPanda C++ (小熊猫 C++ 的安装与启动) ....................12
1.3.2 RedPanda C++ Tutorial (小熊猫 C++ 的使用) .............................................................14
1.4 Defi nition, Characteristics, and Representation of Algorithms
(算法定义、特性及表示) .......................................................................................................... 16
1.4.1 What Is an Algorithm(什么是算法) ...............................................................................16
1.4.2 Features of Algorithms (算法的特性) ............................................................................17
1.4.3 Representation Methods of Algorithms(算法的表示) ...................................................17
Summary (小结) ...................................................................................................................................22
Exercise (习题) .....................................................................................................................................23
Chapter 2
第2章
Sequential Programming 25
顺序程序设计
2.1 Sequential Programming Examples and Program Components
(顺序程序设计举例及程序组成成分) ....................................................................................... 25
2.1.1 Sequential Programming Example (顺序程序设计举例) .............................................26
2.1.2 Program Components(程序组成成分)...........................................................................27
2.2 Basic Data Types (基本数据类型) ......................................................................................... 27
2.2.1 Why Data Types Are Necessary(为什么需要数据类型) ...............................................28
2.2.2 Basic Data Types(基本数据类型 ) .................................................................................28
2.3 Constants and Variables(常量与变量) .................................................................................. 30
2.3.1 Constants (常量) .............................................................................................................31
C 语言程序设计(双语版) II
2.3.2 Variables (变量) ............................................................................................................. 32
2.3.3 Symbolic Constants (符号常量) ................................................................................... 33
2.4 C Operators and Expressions(C 运算符及表达式) .............................................................35
2.4.1 Operator Overview (运算符概述) ................................................................................. 35
2.4.2 Common Operators and Expressions (常用运算符及表达式) ..................................... 35
2.4.3 Type Conversions and Casts (类型转换) ...................................................................... 38
2.5 C Statements(C 语句) .............................................................................................................39
2.5.1 What Are C Statements(什么是 C 语句) ...................................................................... 40
2.5.2 Output Statements (输出语句) ...................................................................................... 41
2.5.3 Input Statements (输入语句)......................................................................................... 43
2.5.4 Single-character Input and Output (单个字符的输入和输出) ..................................... 45
2.6 Comprehensive Cases(综合案例) .........................................................................................47
Summary (小结) .................................................................................................................................. 49
Exercise (习题) .................................................................................................................................... 50
Chapter 3
第3章
Selective Structure Programming 52
选择结构程序设计
3.1 Relational, Logical Operators and Expressions
(关系、逻辑运算符及其表达式) ...............................................................................................52
3.1.1 Why Do We Need Selection Structures(为什么需要选择结构) .................................. 53
3.1.2 Relational Operators and Expressions(关系运算符及其表达式) ................................ 53
3.1.3 Logical Operators and Expressions (逻辑运算符及其表达式) ................................... 54
3.2 Selection Structures Using if and switch Statements
(if 和 switch 语句实现选择结构) ...............................................................................................57
3.2.1 Selection Structures Using if Statements(if 语句实现选择结构) ................................ 57
3.2.2 Using the switch Statement for Multi-branch Selection Structures
(switch 语句实现多分支选择结构) ............................................................................... 64
3.3 Comprehensive Cases(综合案例) .........................................................................................66
Summary (小结) .................................................................................................................................. 71
Exercise (习题) .................................................................................................................................... 72
Chapter 4
第4章
Loop Structure Programming 75
循环结构程序设计
4.1 Why Do We Need a Loop Structure(为什么需要循环结构) ...............................................75
4.2 The While and do...while Statements(while 和 do...while 语句) .......................................77
4.2.1 The While Statements(while 语句) ............................................................................... 77
CONTENTS
目 录 III
4.2.2 The do...while Statement(do...while 语句) .................................................................... 79
4.2.3 Comparison of while and do...while(while 和 do...while 的比较) ............................... 81
4.3 The for Statements (for 语句) ................................................................................................83
4.3.1 Review and Introduction (回顾与引入) ........................................................................ 83
4.3.2 The for Statements to Implement Loops (for 语句实现循环) ...................................... 84
4.3.3 Special Forms of the for Statement (for 语句的特殊形式) .......................................... 87
4.3.4 Comparison of Three Loop Statements (三种循环语句的比较) ................................. 89
4.4 Loop Control Statements(循环控制语句) .............................................................................90
4.4.1 The break Statement(break 语句) .................................................................................. 90
4.4.2 The continue Statement(continue 语句) ........................................................................ 93
4.4.3 Difference Between break and continue(break 和 continue 的区别) ........................... 94
4.5 Nesting of Loops(循环的嵌套) ...............................................................................................95
4.5.1 What Is Nesting of Loops (什么是循环的嵌套) .......................................................... 95
4.5.2 Examples of Loop Nesting (循环嵌套的举例)............................................................. 97
4.6 Comprehensive Cases(综合案例) ...................................................................................... 102
Summary (小结) ................................................................................................................................ 107
Exercise (习题) .................................................................................................................................. 107
Chapter 5
第5章
Batch Processing of Data Using Arrays 110
利用数组批量处理数据
5.1 Definition and Use of One-dimensional Array ( 一维数组的定义和使用 ) ..........................110
5.1.1 Source of Array (数组的来源) .................................................................................... 110
5.1.2 Definition of One-dimensional Array (一维数组的定义) .......................................... 112
5.1.3 Storage of One-dimensional Array (一维数组的存储) .............................................. 112
5.1.4 Reference of One-dimensional Array (一维数组的引用) .......................................... 113
5.1.5 Initialization of One-dimensional Array (一维数组的初始化) .................................. 114
5.2 Two-dimensional Array(二维数组) .......................................................................................116
5.2.1 Definition and Storage Mode of Two-dimensional Array
(二维数组定义及存储方式) ........................................................................................ 116
5.2.2 Reference of Two-dimensional Array (二维数组的引用) .......................................... 117
5.2.3 Initialization of Two-dimensional Array (二维数组的初始化) .................................. 118
5.2.4 Application Example of Two-dimensional Array (二维数组应用举例) .................... 119
5.3 Character Arrays and Strings(字符数组及字符串) ........................................................... 121
5.3.1 Character Array (字符数组) ........................................................................................ 121
5.3.2 String (字符串) ............................................................................................................ 122
5.3.3 String Handling Functions (字符串处理函数) ........................................................... 125
C 语言程序设计(双语版) IV
5.4 Comprehensive Cases(综合案例) ...................................................................................... 128
Summary (小结) ................................................................................................................................ 136
Exercise (习题) .................................................................................................................................. 136
Chapter 6
第6章
Pointer 139
指针
6.1 Pointers and Pointer Variables (指针和指针变量) ........................................................... 139
6.1.1 What Is a Pointer (什么是指针) .................................................................................. 140
6.1.2 Definition and Use of Pointer Variables (指针变量的定义与使用) ........................... 142
6.1.3 Precautions for Using Pointer Variable (指针变量使用注意事项) ............................ 145
6.2 Pointer Reference Array (指针引用数组) .......................................................................... 148
6.2.1 Pointer Variable Points to Array (指针变量指向数组)............................................... 148
6.2.2 Pointer Addition and Subtraction (指针加减运算) ..................................................... 149
6.2.3 Pointers Referencing Array Elements (指针引用数组元素) ...................................... 150
6.3 Pointer Reference String(指针引用字符串) ...................................................................... 153
6.3.1 Storage and Reference of Character Strings (字符串的存储与引用) ........................ 153
6.3.2 Character Array Reference String (字符数组引用字符串) ........................................ 154
6.3.3 Pointer Variable Reference String (指针变量引用字符串) ........................................ 155
6.3.4 Comparison of Character Array and Character Pointer Variable Reference
String Method (字符数组与字符指针变量引用字符串方法的比较) ...................... 157
6.4 Comprehensive Cases(综合案例) ...................................................................................... 158
Summary (小结) ................................................................................................................................ 163
Exercise (习题) .................................................................................................................................. 164
Chapter 7
第7章
Function 167
函数
7.1 Definition of Function (函数的定义) ................................................................................... 168
7.1.1 Why Use Functions (为什么要用函数) ...................................................................... 168
7.1.2 How to Define a Function (怎样定义函数) ................................................................ 170
7.2 Function Declaration and Call (函数的声明和调用) ......................................................... 174
7.2.1 What is Function Declaration and Call (什么是函数的声明和调用) ........................ 174
7.2.2 How Does the Function Work (函数如何工作) .......................................................... 177
7.3 Local and Global Variables (局部变量与全局变量) .......................................................... 178
7.3.1 Scope and Lifetime (作用域和生存期) ...................................................................... 178
7.3.2 Local Variables (局部变量) ......................................................................................... 178
7.3.3 Global Variables (全局变量) ....................................................................................... 180
CONTENTS
目 录 V
7.4 Storage of Variables (变量的存储方式) ............................................................................. 182
7.4.1 What Is the Storage of Variables (什么是变量的存储方式) ...................................... 182
7.4.2 Storage Categories of Local Variables (局部变量的存储类别) ................................. 183
7.4.3 Storage Categories of Global Variables (全局变量的存储类别) ............................... 186
7.5 Arrays as Function Parameters (数组作为函数参数) ...................................................... 188
7.5.1 Array Elements as Function Parameters (数组元素作为函数实参) .......................... 188
7.5.2 Arrays as Function Parameters (数组作为函数参数) ................................................ 190
7.6 Pointers as Function Parameters (指针作为函数参数) ................................................... 193
7.7 Application of Pointer in Function (指针在函数中的应用) ............................................... 198
7.7.1 Pointer to Function (指向函数的指针) ....................................................................... 199
7.7.2 Functions That Return Pointer Values (返回指针值的函数) ..................................... 205
7.8 Recursive Programming (递归程序设计) .......................................................................... 208
7.8.1 What is Recursion (什么是递归) ................................................................................ 208
7.8.2 How Does Recursion Work (递归如何工作) .............................................................. 209
7.8.3 How Is Recursion Designed (递归如何设计)............................................................. 211
7.9 Comprehensive Cases(综合案例) ...................................................................................... 213
Summary (小结) ................................................................................................................................ 218
Exercise (习题) .................................................................................................................................. 218
Chapter 8
第8章
Structures 223
结构体
8.1 Structure Type and Variable Definition(结构体的类型及变量定义) ............................... 224
8.1.1 Why Do We Need a Structure (为什么需要结构体) .................................................. 224
8.1.2 What Is a Structure (什么是结构体) ........................................................................... 225
8.1.3 Structure Variable (结构体变量) ................................................................................. 227
8.1.4 Storage Space Allocation of Structure Variable
(结构体变量的存储空间分配) .................................................................................... 228
8.1.5 Use of Structure Variables (结构体变量的使用)........................................................ 229
8.2 Structure Array and Structure Pointer (结构体数组及结构体指针) ............................... 232
8.2.1 Structure Array (结构体数组) ..................................................................................... 232
8.2.2 Structure Pointer (结构体指针) .................................................................................. 234
8.3 Dynamic Memory Allocation and Linked List Definition
(动态内存分配及链表定义) .................................................................................................... 235
8.3.1 Dynamic Memory Allocation (动态内存分配) .......................................................... 235
8.3.2 Linked List Definition (链表的定义) .......................................................................... 238
C 语言程序设计(双语版) VI
8.4 Creation and Output of Linked List(链表的创建和输出) ................................................. 239
8.4.1 Creation of Linked List (链表的创建) ........................................................................ 240
8.4.2 Output of Linked List (链表的输出)........................................................................... 243
8.5 Insertion, Search and Deletion of Dynamic Linked List
(动态链表的插入、查找和删除) ............................................................................................ 246
8.5.1 Insertion of Linked List (链表的插入) ....................................................................... 246
8.5.2 Search of Linked List (链表的查找) ........................................................................... 250
8.5.3 Deletion of Linked List (链表的删除) ........................................................................ 252
8.6 Comprehensive Cases(综合案例) ...................................................................................... 254
Summary (小结) ................................................................................................................................ 260
Exercise (习题) .................................................................................................................................. 260
Chapter 9
第9章
File 264
文件
9.1 File Open and Close (文件的打开与关闭) ......................................................................... 265
9.1.1 What Is a File (什么是文件) ....................................................................................... 265
9.1.2 Classification of Files (文件的分类) ........................................................................... 265
9.1.3 File Name (文件名) ..................................................................................................... 267
9.1.4 File Buffer (文件缓冲区) ............................................................................................ 267
9.1.5 File Open and Close Operations (文件的打开与关闭操作) ...................................... 269
9.2 File Read and Write Operations (文件的读写操作) ......................................................... 271
9.2.1 File Read and Write Functions (文件读写函数) ......................................................... 272
9.2.2 Application Examples (应用举例) .............................................................................. 273
9.3 Comprehensive Cases(综合案例) ...................................................................................... 278
Summary (小结) ................................................................................................................................ 286
Exercise (习题) .................................................................................................................................. 287