语言教程1 C语言概述..................................................................................................................................61.1 C语言的发展过程..........................................................................................................61.2 当代最优秀的程序设计语言.........................................................................................61.3 C语言版本......................................................................................................................71.4 C语言的特点..................................................................................................................71.5 面向对象的程序设计语言.............................................................................................71.6 C和C++......................................................................................................................81.7 简单的C程序介绍.........................................................................................................81.8 输入和输出函数.............................................................................................................91.9 C源程序的结构特点....................................................................................................101.10 书写程序时应遵循的规则.........................................................................................101.11 C语言的字符集..........................................................................................................111.12 C语言词汇..................................................................................................................111.13 Turbo C 2.0 集成开发环境的使用..............................................................................121.13.1 Turbo C 2.0 简介和启动...................................................................................121.13.2 Turbo C 2.0 集成开发环境...............................................................................131.13.3 File菜单 ............................................................................................................131.13.4 Edit菜单............................................................................................................141.13.5 Run菜单............................................................................................................151.13.6 Compile菜单.....................................................................................................161.13.7 Project菜单 .......................................................................................................181.13.8 Options菜单......................................................................................................191.13.9 Debug菜单........................................................................................................231.13.10 Break/watch菜单.............................................................................................241.13.11 Turbo C 2.0 的配置文件.................................................................................252 程序的灵魂—算法..................................................................................................................252.1 算法的概念...................................................................................................................252.2 简单算法举例...............................................................................................................262.3 算法的特性...................................................................................................................282.4 怎样表示一个算法.......................................................................................................282.4.1 用自然语言表示算法........................................................................................282.4.2 用流程图表示算法............................................................................................282.4.3 三种基本结构和改进的流程图........................................................................322.4.4 用N-S流程图表示算法 .....................................................................................332.4.5 用伪代码表示算法............................................................................................342.4.6 用计算机语言表示算法....................................................................................35第 1 页2.5 结构化程序设计方法...................................................................................................353 数据类型、运算符与表达式..................................................................................................363.1 C语言的数据类型........................................................................................................363.2 常量与变量...................................................................................................................383.2.1 常量和符号常量................................................................................................383.2.2 变量....................................................................................................................393.3 整型数据.......................................................................................................................393.3.1 整型常量的表示方法........................................................................................393.3.2 整型变量............................................................................................................403.4 实型数据.......................................................................................................................433.4.1 实型常量的表示方法........................................................................................433.4.2 实型变量............................................................................................................443.4.3 实型常数的类型................................................................................................453.5 字符型数据...................................................................................................................453.5.1 字符常量............................................................................................................453.5.2 转义字符............................................................................................................463.5.3 字符变量............................................................................................................463.5.4 字符数据在内存中的存储形式及使用方法....................................................473.5.5 字符串常量........................................................................................................483.6 变量赋初值...................................................................................................................483.7 各类数值型数据之间的混合运算...............................................................................493.8 算术运算符和算术表达式...........................................................................................503.8.1 C运算符简介......................................................................................................503.8.2 算术运算符和算术表达式................................................................................513.9 赋值运算符和赋值表达式...........................................................................................533.10 逗号运算符和逗号表达式.........................................................................................543.11 小结.............................................................................................................................553.11.1 C的数据类型...................................................................................................553.11.2 基本类型的分类及特点..................................................................................553.11.3 常量后缀..........................................................................................................563.11.4 常量类型..........................................................................................................563.11.5 数据类型转换..................................................................................................563.11.6 运算符优先级和结合性..................................................................................563.11.7 表达式..............................................................................................................564 最简单的C程序设计—顺序程序设计...................................................................................564.1 C语句概述....................................................................................................................574.2 赋值语句.......................................................................................................................584.3 数据输入输出的概念及在C语言中的实现 ................................................................594.4 字符数据的输入输出...................................................................................................604.4.1 putchar 函数(字符输出函数).......................................................................604.4.2 getchar函数(键盘输入函数).........................................................................604.5 格式输入与输出...........................................................................................................614.5.1 printf函数(格式输出函数)............................................................................614.5.2 scanf函数(格式输入函数)..................................................................................64第 2 页4.6 顺序结构程序设计举例...............................................................................................685 分支结构程序..........................................................................................................................695.1 关系运算符和表达式...................................................................................................695.1.1 关系运算符及其优先次序................................................................................695.1.2 关系表达式........................................................................................................695.2 逻辑运算符和表达式...................................................................................................705.2.1 逻辑运算符极其优先次序................................................................................705.2.2 逻辑运算的值....................................................................................................715.2.3 逻辑表达式........................................................................................................715.3 if语句.............................................................................................................................725.3.1 if语句的三种形式 ..............................................................................................725.3.2 if语句的嵌套 ......................................................................................................755.3.3 条件运算符和条件表达式................................................................................775.4 switch语句.....................................................................................................................785.5 程序举例.......................................................................................................................796 循环控制..................................................................................................................................806.1 概述...............................................................................................................................806.2 goto语句以及用goto语句构成循环..............................................................................806.3 while语句.......................................................................................................................816.4 do-while语句 .................................................................................................................836.5 for语句...........................................................................................................................856.6 循环的嵌套...................................................................................................................886.7 几种循环的比较...........................................................................................................886.8 break和continue语句.....................................................................................................886.8.1 break语句............................................................................................................886.8.2 continue 语句.....................................................................................................896.9 程序举例.......................................................................................................................907 数组 .........................................................................................................................................927.1 一维数组的定义和引用...............................................................................................927.1.1 一维数组的定义方式........................................................................................927.1.2 一维数组元素的引用........................................................................................937.1.3 一维数组的初始化............................................................................................957.1.4 一维数组程序举例............................................................................................957.2 二维数组的定义和引用...............................................................................................977.2.1 二维数组的定义................................................................................................977.2.2 二维数组元素的引用........................................................................................977.2.3 二维数组的初始化............................................................................................987.2.4 二维数组程序举例..........................................................................................1007.3 字符数组.....................................................................................................................1007.3.1 字符数组的定义..............................................................................................1007.3.2 字符数组的初始化..........................................................................................1007.3.3 字符数组的引用..............................................................................................1017.3.4 字符串和字符串结束标志..............................................................................1017.3.5 字符数组的输入输出......................................................................................101第 3 页7.3.6 字符串处理函数..............................................................................................1037.4 程序举例.....................................................................................................................1057.5 本章小结.....................................................................................................................1088 函 数......................................................................................................................................1088.1 概述.............................................................................................................................1088.2 函数定义的一般形式.................................................................................................1108.3 函数的参数和函数的值............................................................................................. 1118.3.1 形式参数和实际参数...................................................................................... 1118.3.2 函数的返回值..................................................................................................1138.4 函数的调用.................................................................................................................1138.4.1 函数调用的一般形式......................................................................................1138.4.2 函数调用的方式..............................................................................................1138.4.3 被调用函数的声明和函数原型......................................................................1148.5 函数的嵌套调用.........................................................................................................1158.6 函数的递归调用.........................................................................................................1178.7 数组作为函数参数.....................................................................................................1208.8 局部变量和全局变量.................................................................................................1248.8.1 局部变量..........................................................................................................1258.8.2 全局变量..........................................................................................................1268.9 变量的存储类别.........................................................................................................1288.9.1 动态存储方式与静态动态存储方式..............................................................1288.9.2 auto变量............................................................................................................1288.9.3 用static声明局部变量 .....................................................................................1298.9.4 register变量.......................................................................................................1308.9.5 用extern声明外部变量....................................................................................1309 预处理命令............................................................................................................................1319.1 概述.............................................................................................................................1319.2 宏定义.........................................................................................................................1319.2.1 无参宏定义......................................................................................................1319.2.2 带参宏定义......................................................................................................1349.3 文件包含.....................................................................................................................1389.4 条件编译.....................................................................................................................1399.5 本章小结.....................................................................................................................14110 指针......................................................................................................................................14110.1 地址指针的基本概念...............................................................................................14110.2 变量的指针和指向变量的指针变量.......................................................................14210.2.1 定义一个指针变量........................................................................................14310.2.2 指针变量的引用............................................................................................14310.2.3 指针变量作为函数参数................................................................................14710.2.4 指针变量几个问题的进一步说明................................................................15010.3 数组指针和指向数组的指针变量...........................................................................15310.3.1 指向数组元素的指针....................................................................................15310.3.2 通过指针引用数组元素................................................................................15410.3.3 数组名作函数参数........................................................................................156第 4 页10.3.4 指向多维数组的指针和指针变量................................................................16310.4 字符串的指针指向字符串的针指变量...................................................................16510.4.1 字符串的表示形式........................................................................................16510.4.2 使用字符串指针变量与字符数组的区别....................................................16810.5 函数指针变量...........................................................................................................16910.6 指针型函数...............................................................................................................17010.7 指针数组和指向指针的指针...................................................................................17110.7.1 指针数组的概念............................................................................................17110.7.2 指向指针的指针............................................................................................17410.7.3 main函数的参数.............................................................................................17610.8 有关指针的数据类型和指针运算的小结...............................................................17710.8.1 有关指针的数据类型的小结........................................................................17710.8.2 指针运算的小结............................................................................................17810.8.3 void指针类型..................................................................................................17811 结构体与共用体..................................................................................................................17811.1 定义一个结构的一般形式.......................................................................................17811.2 结构类型变量的说明...............................................................................................17911.3 结构变量成员的表示方法.......................................................................................18111.4 结构变量的赋值.......................................................................................................18111.5 结构变量的初始化...................................................................................................18211.6 结构数组的定义.......................................................................................................18211.7 结构指针变量的说明和使用...................................................................................18511.7.1 指向结构变量的指针....................................................................................18511.7.2 指向结构数组的指针....................................................................................18611.7.3 结构指针变量作函数参数............................................................................18711.8 动态存储分配...........................................................................................................18811.9 链表的概念...............................................................................................................19011.10 枚举类型.................................................................................................................19111.10.1 枚举类型的定义和枚举变量的说明..........................................................19211.10.2 枚举类型变量的赋值和使用......................................................................19211.11 类型定义符typedef.................................................................................................19312 位运算..................................................................................................................................19412.1 位运算符C语言提供了六种位运算符:...............................................................19412.1.1 按位与运算....................................................................................................19512.1.2 按位或运算....................................................................................................19512.1.3 按位异或运算................................................................................................19612.1.4 求反运算........................................................................................................19612.1.5 左移运算........................................................................................................19612.1.6 右移运算........................................................................................................19612.2 位域(位段)...........................................................................................................19712.3 本章小结...................................................................................................................19913 文件......................................................................................................................................20013.1 C文件概述.................................................................................................................20013.2 文件指针...................................................................................................................201第 5 页13.3 文件的打开与关闭...................................................................................................20113.3.1 文件的打开(fopen函数)................................................................................20113.3.2 文件关闭函数(fclose函数) ......................................................................20313.4 文件的读写...............................................................................................................20313.4.1 字符读写函数fgetc和fputc............................................................................20313.4.2 字符串读写函数fgets和fputs........................................................................20613.4.3 数据块读写函数fread和fwtrite .....................................................................20813.4.4 格式化读写函数fscanf和fprintf....................................................................20913.5 文件的随机读写.......................................................................................................21113.5.1 文件定位........................................................................................................21113.5.2 文件的随机读写............................................................................................21113.6 文件检测函数...........................................................................................................21213.6.1 文件结束检测函数feof函数 .........................................................................21213.6.2 读写文件出错检测函数................................................................................21313.6.3 文件出错标志和文件结束标志置 0 函数....................................................21313.7 C库文件....................................................................................................................21313.8 本章小结...................................................................................................................214
评论