前言
教学建议
篇起步篇
第 0章初识 C程序 ························3
0.1 C语言简介······························3
0.2 C程序基本结构与 main函数 ········4
0.3 C语言的字符集························5
0.4 C语言的单词···························5
0.4.1 关键字······························6
0.4.2 标识符······························6
0.4.3 字面常量···························7
0.5 C语言的符号常量·····················7
0.6 C语言的操作符和表达式 ············8
0.7 C语言的标点符号与注释 ············8
0.8 C语言的语句···························9
0.9 变量 ······································9
0.9.1 C语言变量的定义 ···············9
0.9.2 C语言变量的赋值与初始化··· 10
0.10 数据的输入·························· 11
0.11 数据的输出 ·························· 12
0.12 良好的编程习惯 ···················· 13
0.13 本章小结····························· 15
第二篇进阶篇
第 1章程序的流程及其控制方法···· 18
1.1 顺序流程 ······························ 18
1.2 分支流程 ······························ 19
1.2.1 分支流程的基本形式及其控制语句························· 19
1.2.2 分支流程的嵌套 ················ 21
1.2.3 分支流程的其他形式及控制语句························· 25
1.3 循环流程 ······························ 27
1.3.1 循环流程的基本形式及其控制语句························· 27
1.3.2 循环流程的其他形式及控制语句························· 30
1.3.3 循环流程的嵌套及其优化 ···· 33
1.3.4 循环流程的折断和接续 ······· 38
1.4 流程控制方法的综合运用 ·········· 43
1.5 本章小结 ······························ 50
第 2章程序的模块设计方法 ·········· 51
2.1 子程序 ································· 51
2.2 单模块程序与 C语言函数基础···· 52
2.2.1 函数的定义······················ 52
2.2.2 函数的调用······················ 54
2.2.3 函数的声明及其作用 ·········· 57
2.3 嵌套与递归调用 ····················· 59
2.3.1 函数的一般嵌套调用形式 ···· 59
2.3.2 函数嵌套调用的执行过程 ···· 60
2.3.3 递归函数及其应用 ············· 62
2.4 多模块程序设计方法················ 68
2.4.1 文件包含························· 69
2.4.2 头文件及其作用 ················ 70
2.5* 标识符的属性 ······················· 72
2.5.1 作用域···························· 72
2.5.2 链接 ······························ 75
2.5.3 名字空间························· 77
2.5.4 数据的存储期 ··················· 77
2.6 程序模块设计的优化················ 79
2.6.1 带参数的宏定义 ················ 79
2.6.2 内联函数························· 81
2.6.3 条件编译························· 81
2.7 本章小结 ······························ 84
第 3章程序中操作的描述 ············· 85
3.1 基本操作及其应用··················· 85
3.1.1 算术操作························· 85
3.1.2 关系操作························· 89
3.1.3 逻辑操作························· 91
3.1.4* 位操作 ·························· 92
3.1.5 赋值操作························· 94
3.1.6 条件操作························· 95
3.1.7 逗号操作························· 96
3.2 表达式的有关问题··················· 96
3.2.1 表达式的值与操作符的副作用························ 96
3.2.2 表达式的操作顺序及操作符的优先级和结合性 ···· 97
3.2.3 表达式的书写 ··················· 99
3.3 复杂操作的描述方法简介 ·········· 99
3.4 本章小结 ······························ 99
第 4章程序中数据的描述 ············101
4.1 数据类型 ·····························101
4.2 基本类型 ·····························102
4.2.1 字符型···························102
4.2.2 整型 ·····························105
4.2.3 浮点型···························107
4.2.4 逻辑型···························110
4.2.5 枚举类型·····················110
4.3 基本类型的选用 ····················112
4.4 基本类型的转换 ····················113
4.4.1 类型转换的实质 ···············113
4.4.2 隐式类型转换规则 ············114
4.4.3 强制类型转换的作用 ·········115
4.4.4 类型转换后的数据精度问题 ······················117
4.5 复杂数据的描述方法简介 ·········117
4.6 类型名的自定义 ····················118
4.7 本章小结 ·····························118
第 5章数组 ·······························119
5.1 一维数组 ·····························119
5.1.1 一维数组类型的构造 ·········120
5.1.2 一维数组的定义 ···············120
5.1.3 一维数组的初始化 ············120
5.1.4 一维数组的操作 ···············120
5.2 二维数组 ·····························122
5.2.1 二维数组类型的构造 ·········122
5.2.2 二维数组的定义 ···············122
5.2.3 二维数组的初始化 ············123
5.2.4 二维数组的操作 ···············123
5.3 多维数组 ·····························125
5.4 数组的应用 ··························125
5.4.1 存储一组有序数据 ············126
5.4.2 存储一组有序标志位 ·········130
5.5 本章小结 ·····························133
第 6章指针 ·······························134
6.1 指针的基本概念 ····················134
6.1.1 指针类型的构造 ···············134
6.1.2 指针变量的定义与初始化···························134
6.1.3 指针的基本操作 ···············136
6.2 用指针操纵数组 ····················137
6.2.1 指向一维数组元素的指针变量························137
6.2.2 二级指针························139
6.2.3 数组的指针·····················139
6.3 用指针在函数间传递数据 ·········140
6.3.1 指针类型参数 ··················140
6.3.2 const的作用····················142
6.3.3 指针类型返回值 ···············143
6.4 用指针访问动态变量···············145
6.4.1 通用指针与 void类型 ········145
6.4.2 动态变量的创建 ···············145
6.4.3 动态变量的访问 ···············145
6.4.4 动态变量的撤销 ···············146
6.4.5* 内存泄漏 ······················147
6.4.6* 悬浮指针 ······················147
6.5* 用指针操纵函数 ···················147
6.6 本章小结 ·····························149
第 7章字符串 ····························151
7.1 字符数组 ·····························151
7.1.1 字符数组的定义和初始化····151
7.1.2 字符数组的输入 /输出 ·······152
7.1.3 字符数组作为函数的参数····153
7.1.4 用字符指针操纵字符数组····155
7.2 字符串常量的访问··················156
7.3 字符串的操作 ·······················157
7.4* 指针数组与带形参的 main函数 ····························160
7.5 基于字符数组的信息检索程序····163
7.6 本章小结 ·····························164
第 8章结构 ·······························165
8.1 结构的基本概念 ····················165
8.1.1 结构类型的构造 ···············165
8.1.2 结构变量的定义 ···············166
8.1.3 结构变量的初始化 ············167