前言
教學建議
篇起步篇
第 0章初識 C程序 ························3
0.1 C語言簡介······························3
0.2 C程序基本結構與 main函數(shù) ········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 數(shù)據(jù)的輸入·························· 11
0.11 數(shù)據(jù)的輸出 ·························· 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 循環(huán)流程 ······························ 27
1.3.1 循環(huán)流程的基本形式及其控制語句························· 27
1.3.2 循環(huán)流程的其他形式及控制語句························· 30
1.3.3 循環(huán)流程的嵌套及其優(yōu)化 ···· 33
1.3.4 循環(huán)流程的折斷和接續(xù) ······· 38
1.4 流程控制方法的綜合運用 ·········· 43
1.5 本章小結 ······························ 50
第 2章程序的模塊設計方法 ·········· 51
2.1 子程序 ································· 51
2.2 單模塊程序與 C語言函數(shù)基礎···· 52
2.2.1 函數(shù)的定義······················ 52
2.2.2 函數(shù)的調用······················ 54
2.2.3 函數(shù)的聲明及其作用 ·········· 57
2.3 嵌套與遞歸調用 ····················· 59
2.3.1 函數(shù)的一般嵌套調用形式 ···· 59
2.3.2 函數(shù)嵌套調用的執(zhí)行過程 ···· 60
2.3.3 遞歸函數(shù)及其應用 ············· 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 數(shù)據(jù)的存儲期 ··················· 77
2.6 程序模塊設計的優(yōu)化················ 79
2.6.1 帶參數(shù)的宏定義 ················ 79
2.6.2 內聯(lián)函數(shù)························· 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 表達式的操作順序及操作符的優(yōu)先級和結合性 ···· 97
3.2.3 表達式的書寫 ··················· 99
3.3 復雜操作的描述方法簡介 ·········· 99
3.4 本章小結 ······························ 99
第 4章程序中數(shù)據(jù)的描述 ············101
4.1 數(shù)據(jù)類型 ·····························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 隱式類型轉換規(guī)則 ············114
4.4.3 強制類型轉換的作用 ·········115
4.4.4 類型轉換后的數(shù)據(jù)精度問題 ······················117
4.5 復雜數(shù)據(jù)的描述方法簡介 ·········117
4.6 類型名的自定義 ····················118
4.7 本章小結 ·····························118
第 5章數(shù)組 ·······························119
5.1 一維數(shù)組 ·····························119
5.1.1 一維數(shù)組類型的構造 ·········120
5.1.2 一維數(shù)組的定義 ···············120
5.1.3 一維數(shù)組的初始化 ············120
5.1.4 一維數(shù)組的操作 ···············120
5.2 二維數(shù)組 ·····························122
5.2.1 二維數(shù)組類型的構造 ·········122
5.2.2 二維數(shù)組的定義 ···············122
5.2.3 二維數(shù)組的初始化 ············123
5.2.4 二維數(shù)組的操作 ···············123
5.3 多維數(shù)組 ·····························125
5.4 數(shù)組的應用 ··························125
5.4.1 存儲一組有序數(shù)據(jù) ············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 用指針操縱數(shù)組 ····················137
6.2.1 指向一維數(shù)組元素的指針變量························137
6.2.2 二級指針························139
6.2.3 數(shù)組的指針·····················139
6.3 用指針在函數(shù)間傳遞數(shù)據(jù) ·········140
6.3.1 指針類型參數(shù) ··················140
6.3.2 const的作用····················142
6.3.3 指針類型返回值 ···············143
6.4 用指針訪問動態(tài)變量···············145
6.4.1 通用指針與 void類型 ········145
6.4.2 動態(tài)變量的創(chuàng)建 ···············145
6.4.3 動態(tài)變量的訪問 ···············145
6.4.4 動態(tài)變量的撤銷 ···············146
6.4.5* 內存泄漏 ······················147
6.4.6* 懸浮指針 ······················147
6.5* 用指針操縱函數(shù) ···················147
6.6 本章小結 ·····························149
第 7章字符串 ····························151
7.1 字符數(shù)組 ·····························151
7.1.1 字符數(shù)組的定義和初始化····151
7.1.2 字符數(shù)組的輸入 /輸出 ·······152
7.1.3 字符數(shù)組作為函數(shù)的參數(shù)····153
7.1.4 用字符指針操縱字符數(shù)組····155
7.2 字符串常量的訪問··················156
7.3 字符串的操作 ·······················157
7.4* 指針數(shù)組與帶形參的 main函數(shù) ····························160
7.5 基于字符數(shù)組的信息檢索程序····163
7.6 本章小結 ·····························164
第 8章結構 ·······························165
8.1 結構的基本概念 ····················165
8.1.1 結構類型的構造 ···············165
8.1.2 結構變量的定義 ···············166
8.1.3 結構變量的初始化 ············167