
学习笔记
wu1373369
A Very Important Pig!
展开
-
指针之前的
int num[32] = {1}; 只能给num[0]赋“1”,其于还的还是0。 char *p = "hello world";*p = a; 段错误:常量"hello world" 存在 .rodata 只读数据段。 全局变量:先定义的为低地址。局部变量:先定义的为高地址。 struct test var;struct tse原创 2009-03-19 17:58:00 · 343 阅读 · 0 评论 -
A example of pointer
1 #include 2 3 typedef struct test * p_t; 4 5 struct test{char a, b, c,d;}; 6 7 int main(void) 8 { 9 int a = 0x12345678; 10 11 printf("a: %x, b: %x, c: %x, d: %x/n", ((p_t)&a)->a原创 2009-03-19 18:51:00 · 394 阅读 · 0 评论 -
A wrong example of pointer
char ch;void f(char *p){p = &ch;} int main(void){ char *p = (char *)0x0; f(p); *p = a; putchar(*p); return 0;}//-------the right function-------//--void f(char *原创 2009-03-19 18:36:00 · 428 阅读 · 0 评论 -
malloc的 free
这两天在做练习,有几个错误,写下来,方便以后看!1, 调 malloc 后没有 free ,完全中了老师的着了!如果是服务器程序的话就会造成内存泄露,因为这块空间系统使用不了了,自己又已经没用了!还有 fopen 后要fclose,fopen 一定检查打开是否成功!2, 这个错误我找了好久,小堆法或大堆法(优先队列),malloc 分配数组后,下标从 1 开始(这样使用起来比较方便),方法原创 2009-03-31 15:00:00 · 352 阅读 · 0 评论