随笔分类 - C Primer Plus
摘要:开发步骤: 1. 建立抽象 自然语言描述 2. 建立接口 queue.h 编写类型的定义、结构体的定义、宏的定义、函数声明、include等内容 3. 实现接口 queue.c 编写函数的实现 4. 使用接口 main.c list的使用 5. 编译过程 编译环境 : unix 、linux 方法
阅读全文
摘要:开发步骤: 1. 建立抽象 自然语言描述 2. 建立接口 list.h 编写类型的定义、结构体的定义、宏的定义、函数声明、include等内容 3. 实现接口 list.c 编写函数的实现 4. 使用接口 main.c list的使用 5. 编译过程 编译环境 : unix 、linux 方法 1
阅读全文
摘要:#include <stdio.h> int main(void) { char * name; puts("第一次接受键盘输入:1 2 3 4 5"); int d ; scanf("%d",&d); printf("打印1:%d\n", d ); //清空缓冲区 while(getchar()
阅读全文
摘要:/* filems1.c -- 使用一个结构数组 */ #include <stdio.h> #include <string.h> #include <stdlib.h> #define TSIZE 45 //定义存储电影名称数组的大小 //定义电影struct struct film { cha
阅读全文
摘要:#include <stdio.h> #include <limits.h> //CHAR_BIT表示当前系统char的位数,也就是每个byte的位数 #include <stdlib.h> int main() { printf("查看当前系统byte的bit数:%dbits\n",CHAR_BI
阅读全文
摘要:#include <stdio.h> //fopen函数的包 int main() { unsigned char ch = 'a'; printf("二进制 01100001 的真值::%d\n", ch ); unsigned char ch1 = ~ch; printf("二进制 011000
阅读全文
摘要:#include <stdio.h> //定义一个参数类型为 函数指针的函数 int calc(int x, int y, int (*pt)(int, int) ); int add(int,int); int sub(int,int); int getSum(int,int); int getG
阅读全文
摘要:#include <stdio.h> //fopen函数的包 #include <stdlib.h> //exit()函数的包 #include <string.h> //typedef为数据类型搞一个别名,规范这个别名通常会用大写 typedef char * STRING; //用define来
阅读全文
摘要:#include <stdio.h> //fopen函数的包 #include <stdlib.h> //exit()函数的包 #include <string.h> //定义一个枚举类型(默认从0开始) enum ctype1 { one = 6, two, three, four, five}
阅读全文
摘要:#include <stdio.h> //fopen函数的包 #include <stdlib.h> //exit()函数的包 #include <string.h> //定义结构 struct Person{ char id; int name [4]; double score; }; //定义
阅读全文
摘要:#include <stdio.h> //fopen函数的包 #include <stdlib.h> //exit()函数的包 #include <string.h> //定义一个带有匿名结构成员的结构 struct Person{ char id; int name [4]; struct {ch
阅读全文
摘要:#include <stdio.h> //fopen函数的包 #include <stdlib.h> //exit()函数的包 #include <string.h> //定义一个结构- 把struct Person当做一种数据类型 struct Person{ char id; int name
阅读全文
摘要:#include <stdio.h> //fopen函数的包 #include <stdlib.h> //exit()函数的包 #include <string.h> //定义一个结构- 把struct Person当做一种数据类型 struct Person{ int id; char name
阅读全文
摘要:#include <stdio.h> //fopen函数的包 #include <stdlib.h> //exit()函数的包 #include <unistd.h> //定义一个结构- 把struct Person当做一种数据类型 struct Person{ char *name; int ag
阅读全文
摘要:#include <stdio.h> //fopen函数的包 #include <stdlib.h> //exit()函数的包 #include <unistd.h> //定义一个结构- 把struct Person当做一种数据类型 struct Person{ char *name; int ag
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> #include <unistd.h> //1.静态数组 int i_arr1[3] = {1, 2, 3}; int size = 3; int main() { //创建数组的三种方法 /*1.静态数组 特点:1.用常
阅读全文
摘要:/* --生成随机数的函数(返回一个0~32768的伪随机数)*/ static unsigned long int next = 1; //种子 unsigned int rand0() { /* 生成伪随机数的魔术公式*/ next = next * 1103515245 + 123456; r
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> int value1 = 100; //文件作用域、外部链接、静态存储期 int static value2 = 99; //文件作用域(仅限翻译单元)、内部链接、静态存储期 void isOk(); void isOk1
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> void isOk(); int main() { isOk(); isOk(); isOk(); int index; return 0; } void isOk() { int index ; static int c
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> int main() { const char *pt = "abcdef"; /* 1.abcdef字符串字面量对象 2.字符数组对象(单个元素也是对象) 3.标识符为pt的对象,存储字符串的地址 const 修饰的是字
阅读全文