本書共分11章,第1章介紹了程序設(shè)計(jì)基本知識、C語言基本概念、特點(diǎn)和結(jié)構(gòu)等;第2章介紹了C語言中數(shù)據(jù)類型、常用的運(yùn)算符、算術(shù)表達(dá)式和數(shù)據(jù)類型間的運(yùn)算等;第3章介紹了C語言中常用的輸入、輸出函數(shù)以及順序結(jié)構(gòu)的程序設(shè)計(jì)方法;第4章介紹了關(guān)系運(yùn)算符、邏輯運(yùn)算符、條件運(yùn)算符、if語句的三種形式及switch語句;第5章介紹了C語言中while、do…while和for三種循環(huán)語句、控制語句break、continue和循環(huán)的嵌套;第6章介紹了自定義函數(shù)的定義、自定義函數(shù)的調(diào)用、 函數(shù)的遞歸調(diào)用、變量的存儲類型和外部函數(shù)與內(nèi)部函數(shù);第7章介紹了數(shù)組的定義、初始化和引用、常用字符串函數(shù)、數(shù)組名作函數(shù)參數(shù)等;第8章介紹了指針變量的定義與賦值、常用的針運(yùn)算符、參數(shù)指針的使用、多級指針和指針與數(shù)組的關(guān)系;第9章介紹了戶自定義數(shù)據(jù)類型的基本概念、結(jié)構(gòu)體類型的定義、結(jié)構(gòu)體變量定義、初始化和引用;typedef定義類型、結(jié)構(gòu)體指針和鏈表等;第10章介紹了文件的基本概念、文件指針的定義及賦值和常用的文件操作函數(shù);第11章介紹了預(yù)處理命令的基本概念、不帶參的宏定義、帶參數(shù)的宏定義、文件包含和條件編譯的基本用法。每一章都配備了一定數(shù)量的習(xí)題。
孫輝,1959生,男,教授,碩士研究生導(dǎo)師。江西省政協(xié)委員,南昌工程學(xué)院信息工程學(xué)院院長。全國水利水電類專業(yè)教學(xué)指導(dǎo)委員會委員;中國人工智能學(xué)會粗糙集與軟計(jì)算專業(yè)委員會委員;江西省高校"十一五”、"十二五”計(jì)算機(jī)應(yīng)用技術(shù)重點(diǎn)學(xué)科帶頭人;南昌市"五一”勞動獎?wù)芦@得者;水利部及江西省優(yōu)秀教師;首屆江西省普通高校教學(xué)名師獎獲得者。
第1 章 緒論 ··································.1
1.1 程序設(shè)計(jì)語言的發(fā)展 ············.1
1.1.1 程序 ························.1
1.1.2 程序設(shè)計(jì) ··················.1
1.1.3 程序設(shè)計(jì)語言 ············.2
1.2 C 語言 ·······························.3
1.2.1 C 語言的特點(diǎn) ·············.3
1.2.2 C 語言的結(jié)構(gòu) ·············.6
1.3 幾個簡單的 C 語言程序 ··········.6
1.4 C 語言程序的結(jié)構(gòu)特點(diǎn) ··········.9
1.5 C 語言程序的開發(fā)設(shè)計(jì)
過程 ··································.9
1.6 程序設(shè)計(jì)的過程 ················.10
1.7 書寫程序時應(yīng)遵循的規(guī)則 ·····.11
1.8 對于 C 語言學(xué)習(xí)的認(rèn)識 ·········.11
習(xí)題 ······································.12
第2 章 基本數(shù)據(jù)類型及運(yùn)算符 ········.15
2.1 C 語言的字符集、關(guān)鍵字
和標(biāo)識符 ··························.15
2.1.1 字符集 ···················.15
2.1.2 關(guān)鍵字 ···················.15
2.1.3 標(biāo)識符 ···················.16
2.2 C 語言的數(shù)據(jù)類型 ··············.16
2.2.1 數(shù)據(jù)及數(shù)據(jù)類型
的概念 ···················.16
2.2.2 基本類型 ················.17
2.2.3 構(gòu)造類型 ·················.17
2.2.4 其他類型 ·················.17
2.3 常量與變量 ·······················.18
2.3.1 常量 ·······················.18
2.3.2 變量 ·······················.19
2.4 整型數(shù)據(jù) ··························.20
2.4.1 整型常量 ·················.20
2.4.2 整型變量 ·················.21
2.5 實(shí)型數(shù)據(jù) ··························.23
2.5.1 實(shí)型常量 ·················.23
2.5.2 實(shí)型變量 ·················.23
2.6 字符數(shù)據(jù) ··························.23
2.6.1 字符常量 ·················.23
2.6.2 轉(zhuǎn)義字符 ·················.24
2.6.3 字符變量 ·················.24
2.6.4 字符串常量 ··············.25
2.7 運(yùn)算符和表達(dá)式 ·················.26
2.7.1 算術(shù)運(yùn)算符和
算術(shù)表達(dá)式 ··············.27
2.7.2 賦值運(yùn)算符和
賦值表達(dá)式 ··············.28
2.7.3 自增、自減運(yùn)算符 ····.30
2.7.4 逗號運(yùn)算符和
逗號表達(dá)式 ··············.31
2.7.5 sizeof 運(yùn)算符 ············.31
2.7.6 位運(yùn)算 ····················.32
2.8 運(yùn)算符的優(yōu)先級 ·················.35
2.9 混合運(yùn)算中的類型轉(zhuǎn)換問題 ·.36
2.9.1 自動類型轉(zhuǎn)換 ··········.36
2.9.2 強(qiáng)制類型轉(zhuǎn)換 ··········.37
2.10 小結(jié) ······························.38
習(xí)題 ······································.39
第3 章 順序結(jié)構(gòu) ··························.42
3.1 C 語言語句 ·······················.42
3.2 數(shù)據(jù)的輸出和輸入 ·············.43
3.2.1 printf( )函數(shù)和
scanf( )函數(shù) ·············.43
3.2.2 其他輸入輸出函數(shù) ····.50
3.3 順序結(jié)構(gòu)程序設(shè)計(jì)舉例 ·······.53
3.4 小結(jié) ································.58
習(xí)題 ······································.58
第4 章 分支結(jié)構(gòu) ··························.62
4.1 邏輯判斷 ·························.62
4.1.1 關(guān)系運(yùn)算符與
關(guān)系表達(dá)式 ·············.62
4.1.2 邏輯運(yùn)算符和
邏輯表達(dá)式 ·············.63
4.1.3 條件運(yùn)算符 ·············.65
4.2 if 語句 ·····························.66
4.2.1 if 語句的簡單形式 ·····.66
4.2.2 if…else 語句 ············.69
4.2.3 if…else if…else
語句 ······················.73
4.2.4 if 語句的嵌套 ···········.76
4.3 if 語句應(yīng)用舉例 ·················.79
4.4 switch 語句 ·······················.83
4.5 無條件轉(zhuǎn)移語句(goto) ·····.87
4.6 小結(jié) ································.88
習(xí)題 ······································.88
第5 章 循環(huán)結(jié)構(gòu) ··························.92
5.1 while 語句 ························.92
5.1.1 while 語句的結(jié)構(gòu) ······.93
5.1.2 while 語句的使用 ······.95
5.2 do…while 語句 ··················.100
5.2.1 do…while 語句的
結(jié)構(gòu) ······················.100
5.2.2 do…while 語句的
使用 ······················.101
5.3 for 語句 ···························.103
5.3.1 for 語句的結(jié)構(gòu) ·········.103
5.3.2 for 語句的使用 ·········.105
5.4 循環(huán)中 break 和 continue
語句的使用 ······················.108
5.5 循環(huán)語句的嵌套 ················.111
5.6 3 種循環(huán)的比較 ·················.113
5.7 循環(huán)語句的綜合應(yīng)用 ··········.114
5.8 小結(jié) ·······························.119
習(xí)題 ······································.119
第6 章 函數(shù) ·······························.124
6.1 函數(shù)的概念 ······················.124
6.1.1 庫函數(shù) ···················.125
6.1.2 自定義函數(shù) ·············.125
6.1.3 自定義函數(shù)的調(diào)用 ···.128
6.2 變量的作用域和存儲類別 ····.133
6.2.1 變量的作用域 ··········.134
6.2.2 變量的存儲類別·······.137
6.3 內(nèi)部函數(shù)和外部函數(shù) ··········.141
6.3.1 內(nèi)部函數(shù) ················.141
6.3.2 外部函數(shù) ················.141
6.4 函數(shù)的遞歸調(diào)用 ················.142
6.5 模塊程序設(shè)計(jì)實(shí)例 ·············.146
6.6 小結(jié) ·······························.156
習(xí)題 ······································.157
第7 章 數(shù)組 ·······························.162
7.1 一維數(shù)組 ·························.163
7.1.1 一維數(shù)組的定義·······.163
7.1.2 一維數(shù)組的初始化 ···.164
7.1.3 一維數(shù)組的引用·······.164
7.2 二維數(shù)組及多維數(shù)組 ··········.170
7.2.1 二維數(shù)組的定義 ······.170
7.2.2 二維數(shù)組的初始化 ···.170
7.2.3 二維數(shù)組元素的
引用 ·····················.171
7.2.4 三維數(shù)組及討論 ······.172
7.2.5 二維數(shù)組的應(yīng)用 ······.172
7.3 字符數(shù)組與字符串 ············.174
7.3.1 字符數(shù)組和字符串
的初始化 ···············.174
7.3.2 常用字符串庫函數(shù) ···.178
7.3.3 字符數(shù)組與字符串
的應(yīng)用 ··················.180
7.4 數(shù)組作為函數(shù)的參數(shù) ·········.183
7.5 數(shù)組綜合應(yīng)用舉例 ············.186
7.6 小結(jié) ·······························.192
習(xí)題 ·····································.193
第8 章 指針 ·······························.199
8.1 變量的地址和指針 ············.199
8.1.1 指針變量的定義 ······.200
8.1.2 指針運(yùn)算符 ············.200
8.1.3 指針的運(yùn)算 ············.203
8.1.4 指針運(yùn)算符與單目
運(yùn)算符的優(yōu)先級 ······.204
8.2 指針變量作為函數(shù)參數(shù) ······.207
8.3 多級指針 ························.210
8.4 指針與數(shù)組 ·····················.211
8.4.1 指針與一維數(shù)組 ······.211
8.4.2 指針與二維數(shù)組 ······.213
8.4.3 數(shù)組指針 ···············.215
8.4.4 指針數(shù)組 ···············.216
8.5 指向函數(shù)的指針 ···············.217
8.5.1 指向函數(shù)指針的
定義 ·····················.217
8.5.2 指向函數(shù)指針的
引用 ·····················.217
8.6 命令行參數(shù)的使用 ············.220
8.7 指針應(yīng)用程序舉例 ············.222
8.8 小結(jié) ·······························.225
習(xí)題 ······································.225
第9 章 用戶自定義數(shù)據(jù)類型 ··········.230
9.1 結(jié)構(gòu)類型 ·························.230
9.1.1 結(jié)構(gòu)類型的定義·······.230
9.1.2 結(jié)構(gòu)類型變量的
定義 ······················.231
9.1.3 結(jié)構(gòu)類型變量的
初始化和引用 ··········.233
9.1.4 結(jié)構(gòu)類型數(shù)組 ··········.237
9.1.5 結(jié)構(gòu)類型指針 ··········.239
9.1.6 結(jié)構(gòu)體在函數(shù)中的
使用 ······················.240
9.1.7 鏈表的概念及
簡單應(yīng)用 ················.245
9.2 位域 ·······························.258
9.3 聯(lián)合類型 ·························.260
9.4 枚舉類型 ·························.263
9.5 數(shù)據(jù)類型別名的定義 ··········.267
9.6 小結(jié) ·······························.269
習(xí)題 ······································.270
第10 章 文件 ······························.274
10.1 文件的概念 ····················.274
10.1.1 C 語言中的文件 ······.274
10.1.2 標(biāo)準(zhǔn)級(流式)
輸入輸出 ················.274
10.1.3 文件指針 ··············.275
10.2 文件的打開與關(guān)閉 ···········.275
10.2.1 文件的打開 ···········.275
10.2.2 文件的關(guān)閉 ···········.276
10.3 常用文件讀寫函數(shù) ···········.278
10.3.1 字節(jié)級讀寫函數(shù) ·····.278
10.3.2 字符串級讀寫
函數(shù) ······················.280
10.3.3 格式化讀寫函數(shù) ·····.281
10.3.4 塊讀寫函數(shù) ···········.284
10.4 文件定位與隨機(jī)讀寫 ········.287
10.5 文件操作錯誤檢測 ···········.289
10.6 小結(jié) ·····························.290
習(xí)題 ·····································.290
第11 章 預(yù)處理命令 ·····················.294
11.1 宏定義 ··························.294
11.1.1 無參數(shù)的宏定義 ·····.294
11.1.2 帶參數(shù)的宏定義 ·····.298
11.2 文件包含 ·······················.300
11.3 條件編譯 ·······················.301
11.3.1 第 1 種條件編譯 ······.301
11.3.2 第 2 種條件編譯 ······.302
11.3.3 第 3 種條件編譯 ······.302
11.4 小結(jié) ·····························.304
習(xí)題 ······································.304
附錄A 常用庫函數(shù) ·······················.307
A.1 數(shù)學(xué)函數(shù) ························.307
A.2 字符函數(shù)和字符串函數(shù) ······.308
A.3 輸入輸出函數(shù) ··················.309
A.4 動態(tài)存儲分配函數(shù) ············.311
附錄B 常用字符與ASCII 碼
對照表 ·····························.312
參考文獻(xiàn) ······································.314