上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 37 下一页
摘要: 三者的区别 malloc --->分配内存 calloc ---->分配内存初始化为0 realloc---->重新调整已经分配好的内存 阅读全文
posted @ 2012-10-04 13:10 Epirus 阅读(127) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>void foo(char c[10]){ c++; c[0]='a';}main(){ char s[10]={'1','2','3','4'}; foo(s); printf("%s",s);}输出的结果是:1a34从上面的代码中我们可以发现你可以对c指针进行操作,但是你是无法在main函数中对s进行操作,其实这个也很好理解,如果你在main中使用了s++那么数据将会丢失,有可能无法找回原先的地 阅读全文
posted @ 2012-09-29 14:39 Epirus 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 今天考试,然后碰到一个数据类型的问题,气死我了。int --->4Bunsigned int ->4Bunsigned short ->2Blong a->8Bunsigned short a->2Bshort a->2Bunsigned long a->8Blong long a->4B 阅读全文
posted @ 2012-09-28 14:51 Epirus 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 今天考试碰到一个问题,其实,我们一般所执行函数时,只要这个函数中不含局部全局变量,那么这个函数就是安全的。所以我们在递归分析的时候,先分析最外面一层跟,分析最里面一层没有什么区别,right?#include <stdio.h>#include <stdlib.h>void e(int n){ if(n>0){ e(--n); printf("%d",n); e(--n); }}int main(){ int a; a=3; e(a);}result=0120 阅读全文
posted @ 2012-09-28 14:14 Epirus 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 今天有个考试,非常有意思,就是局部全局变量#include <stdio.h>#include <stdlib.h>int counter(int i){static int count=0;count=count+i;return (count);}int main(){ int i,j; for(i=0;i<=5;i++) j=counter(i); printf("%d",j);}其实这个问题可以这么理解,假如每次count都置0,那么局部的全局变量还有什么意义呢,所以static int count只会执行一次。所以count不会每次都 阅读全文
posted @ 2012-09-28 13:56 Epirus 阅读(121) 评论(0) 推荐(0) 编辑
上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 37 下一页