C
一颗菜薯
这个作者很懒,什么都没留下…
展开
-
知识点总结(7) [结构体]
if(a <= 0) 推荐:(a < 1) 逼近条件变量意义单一 函数意义单一数据区 存放 : 全局变量 静态局部/全局变量 字符串常量代码区堆区栈区编译时进行类型检查数组名 例外(1)sieof 整个大小 首元素地址函数在栈帧中退出时 栈帧被回收 但其中的数据还有残留 只有在另一个函数需开辟此栈帧前 window系统会用ccccccccc清理两个数组名 不可以相...原创 2019-04-27 14:05:13 · 138 阅读 · 0 评论 -
const & 指针
红线左侧有const 为 解引用之后的值 不可被改变红线右侧有const 为 自身p对应的(a) 不可被改变原创 2019-03-30 20:33:31 · 583 阅读 · 1 评论 -
引用编译时识别为指针
引用 (别名)==>系统识别为常性的指针(从逻辑上看有区别 从系统上没区别)逻辑上 使用引用比指针更好理解int &b = a; // 引用int * const b = &a; // 系统识别原文件 .cpp -> .ivoid fun(int & a){ int *p = a; *a += 10; *p += 10;}int...原创 2019-05-08 20:12:35 · 143 阅读 · 0 评论 -
C语言小总-----malloc free
#include<malloc.h>//头文件malloc 开辟的是字节数int main(){ int *ip = NULL; char *cp = NULL; int n = 0; cin>>n; if(n<=0) return 0; ip = (int *)malloc(sizeof(int)*n); for(int i = 0;i<...原创 2019-05-19 16:59:06 · 154 阅读 · 0 评论 -
C语言小总-----字符串 &一丢丢void指针
char str1[20] = {"helloworld"};char *sp = "helloworld";两者区别:str1 是数组 在栈上开辟20个空间 前面存放helloworld 后面放0 其内容可以被改变*sp指针存放在栈上 其指向的字符串在数据区 只读特性char str[30];//定义一个数组=>缓冲区scanf("%s",str);printf("%s \...原创 2019-05-18 19:26:23 · 154 阅读 · 0 评论 -
C知识点小总
数组在型参中的写法int Fun(int arr[10]) //型参退化成指针int Fun(int arr[])int Fun(int *arr)//三个等价const 和 * 的结合规律const//与类型结合*//与类型名结合预编译时处理 #编译时处理 类型 语法 sizeof 对关键字解析(转换)了int a = 10; // 编译后 int a = ...原创 2019-05-23 21:47:16 · 93 阅读 · 1 评论 -
指针加const约束能力的变化
指针加const 只能缩小约束能力 不能扩大int a = 10;int const *p = &a;int *s1 = p;//Fint const *s2 = p;//Tint * const s3 = p;// Fconst int * const s4 = p;//Tint a = 10;int * const p = &a;int *s1 = p;...原创 2019-05-23 21:47:54 · 135 阅读 · 0 评论 -
C 素数 九九表 闰年
打印100~200 之间的素数输出乘法口诀表判断1000年—2000年之间的闰年 #include<stdio.h>``void Prime() { printf("100~200 prime number: "); for(int i = 100;i <=200;i++) ...原创 2019-03-18 20:49:13 · 134 阅读 · 0 评论