2016年3月14日

C语言 野指针与空指针

摘要: //野指针与空指针的区别 #define _CRT_SECURE_NO_WARNINGS #include #include //野指针是指存在一个指针变量,但是这个指针变量指向的内存空间已经被释放,这时候指针的值还是不为空 //再次调用free()函数就会报错;空指针是值为NULL的指针变量 void main(){ int *p = (int *)malloc(sizeof(i... 阅读全文

posted @ 2016-03-14 09:46 寒魔影 阅读(960) 评论(0) 推荐(0)

2016年3月9日

C语言 日常小结

摘要: 1.当数组当作函数参数的时候会退化为指针 #include<stdio.h> #include<stdlib.h> void sort(int a[]){ int num = sizeof(a); printf("数组的大小num=%d\n", num);//打印4,此时a是一个指针 //打印数组 阅读全文

posted @ 2016-03-09 14:03 寒魔影 阅读(445) 评论(0) 推荐(0)

C语言 原码--反码--补码

摘要: //原码,反码,补码 #include<stdio.h> #include<stdlib.h> //数值的表示方法——原码、反码和补码 //原码:最高位为符号位,其余各位为数值本身的绝对值 //反码: //正数:反码与原码相同 //负数:符号位为1,其余位对原码取反 //补码: //正数:原码、反码 阅读全文

posted @ 2016-03-09 10:24 寒魔影 阅读(714) 评论(0) 推荐(0)

2016年3月7日

C语言 百炼成钢18

摘要: //题目52:用递归打印以下图形 //* //*.*. //*..*..*.. //*...*...*...*... //*....*....*....*....*.... #include #include //分析:熟练使用递归,递归比较难以理解,可以先写出for循环,再写递归 //递归的一般形式 //void 函数名(参数列表){ // if (终止条件) // { // ... 阅读全文

posted @ 2016-03-07 23:20 寒魔影 阅读(277) 评论(0) 推荐(0)

C语言 共用体

摘要: //共用体 union #define _CRT_SECURE_NO_WARNINGS #include #include #include // union 共用体,构造数据类型,也叫联合体,用途:十几个不同类型的变量共占一段内存(相互覆盖) //共用体在类型定义的时候并不分配内存,定义共用体变量的时候才分配内存 union data{ char c; int a[10... 阅读全文

posted @ 2016-03-07 15:04 寒魔影 阅读(700) 评论(0) 推荐(0)

C语言 结构体

摘要: //结构体 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #include<string.h> //结构体是一种构造数据类型,用途把不同的数据组合成一个整体 //结构体变量数据大,作为参数的时候一般会使用结构 阅读全文

posted @ 2016-03-07 15:02 寒魔影 阅读(423) 评论(0) 推荐(0)

C语言错误 BUG报错整理

摘要: 错误一 关键字:间接寻址级别不同 #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> char strcat(char *a,char *b) { char c[199] 阅读全文

posted @ 2016-03-07 10:58 寒魔影 阅读(1022) 评论(0) 推荐(0)

2016年3月4日

C语言 const与指针

摘要: //const与指针 #include #include void main(){ int num1 = 10; const int num2 = 10; const int *p; p = &num1; //p可以变化 p = &num2; //p可以变化 //*p = 5; 报错 这表明p指向一个常量,这个指针不可以改变指向的数据... 阅读全文

posted @ 2016-03-04 15:41 寒魔影 阅读(255) 评论(0) 推荐(0)

2016年3月3日

C语言 复杂队列(链表队列)

摘要: //复杂的队列二 --链表队列 #include #include #define datatype int struct queuelink{ datatype data;//数据 int high;//优先级 struct queuelink *pnext;//下一节点的指针 }; typedef struct queuelink QueueLink; /... 阅读全文

posted @ 2016-03-03 14:05 寒魔影 阅读(568) 评论(0) 推荐(0)

2016年3月2日

C语言 简单的队列(数组队列)

摘要: //简单的队列 #include #include #define datatype int #define N 10 //定义队列结构体 struct queue{ int front;//队头 int endline;//队尾 datatype data[N];//数据 }; typedef struct queue Queue; Queue myQueue... 阅读全文

posted @ 2016-03-02 17:47 寒魔影 阅读(4441) 评论(0) 推荐(0)

导航