HBK2012 发表于 2012-2-19 12:38:26

sizeof(str)与sizeof(*str)的区别

刚接触C开发,虽然以前觉的自己的C语言基础还行,但真正编写起代码来还是会碰到很多问题。

比如有个简单的结构体
C/C++ code
struct test {   int id ;   char
*name ;   struct test *next ;}test_;char
*str =
"hello,the world";test_->name =
*str;/*错误1: 不说了,哎。。*/


练习下链表的起因,在赋值test->name的时候需要开辟空间,所以用到标题上的sizeof().打算把 *str赋过去,
发现sizeof(str)与sizeof(*str)都可以?
页: [1]
查看完整版本: sizeof(str)与sizeof(*str)的区别