【 以下文字转载自 JobHunting 讨论区 】 发信人: GreenBean (I am THE Greenbean), 信区: JobHunting 标 题: char *p = "string literal"; 和 char a[] = "string liter 发信站: BBS 未名空间站 (Tue Aug 12 01:56:44 2008) char *f(void) { char a[] = "string literal"; return a; } //bad: returning address of local variable or temporary char *f(void) { char *p = "string literal"; return p; }//Is this good? 这里这个p怎么理解,不也是local的吗?据说是static的所以没问题?可是没定义是static 的啊?
h*a
4 楼
【 以下文字转载自 Hardware 讨论区 】 发信人: hahaha (个人), 信区: Hardware 标 题: where can I buy a replacement receiver for logitech MX3200 mouse and keyboard? 发信站: BBS 未名空间站 (Fri Aug 1 16:05:07 2008) I bought a set of MX3200 laser mouse and keyboard last Nov. But the usb receiver is broken by my son. Where can I buy a replacement receiver? Can I get it in a local store? Thanks a lot!
【在 h****a 的大作中提到】 : 【 以下文字转载自 Hardware 讨论区 】 : 发信人: hahaha (个人), 信区: Hardware : 标 题: where can I buy a replacement receiver for logitech MX3200 mouse and keyboard? : 发信站: BBS 未名空间站 (Fri Aug 1 16:05:07 2008) : I bought a set of MX3200 laser mouse and keyboard last Nov. But the usb : receiver is broken by my son. Where can I buy a replacement receiver? Can I : get it in a local store? Thanks a lot!
【在 h**********c 的大作中提到】 : there should be a file I don't recall the extension, file name same as the : fig file. : rename it : or read the help
G*n
23 楼
学过,就是不知道它属于哪一种
【在 f*****Q 的大作中提到】 : 现在的同校们是不是都不学内存管理啊?
h*c
24 楼
I don't recall it is the .m bak or the .fig bak. Just check it , both the .m and the .fig!
【在 E*V 的大作中提到】 : xxxxx.asv?
G*n
25 楼
岂不是有memory leak caller可以释放这部分内存吗?比如free(p) 谢谢
【在 t****t 的大作中提到】 : p指向的地址从来没有变过, 这部分内存也不会被释放
a*l
26 楼
It's good if you understand why. But, if you don't understand why this works , better do not try to understand and use this techinique, because it is going to do more harm than good to you. The point is, if you truly understand the C language and how computer works, you naturally knows why this works or might not work. If you don't understand, that means your level is not up to using these kind of technique.
"string literal" is pre-allocated in .rodata section at compile time (no memory lead proble). a[] is local to the stack but not directly point to the string (see the assemble code). p directly points to "string literal". .section .rodata .LC0: .string "string literal"