本文介绍了解释指针的指针问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新成C,我试图让指针一握。我碰到这个前pression
I'm new into C and I'm trying to get a grip on pointers. I came across this expression
char *foo = *(char **)bar;到底是怎么回事呢?据我所知,是* **的指针是指针的指针,但我真的不明白是什么 *(字符**)栏
编辑:值得一提的是酒吧声明为const void *的栏
edit: worth to mention that bar is declared as const void *bar
推荐答案初学者和专家都可以受益于获取基础非常坚实的。
Beginners and experts alike can benefit from getting the basics really solid.
- A的变量的类型t 的是一种可以用来存储或取得一个的值的存储位置的类型t。
- A的指针的以T是的值的
- 运用对其操作 * 来一个指针T产生的类型t变量。
- A "variable of type t" is a storage location which can be used to store or fetch a value of type t.
- A "pointer to t" is a value.
- Applying the dereferencing operator * to a "pointer to t" produces a "variable of type t".
那么,我们得到了?
void *bar = whatever; char *foo = *(char **)bar;- 栏的类型是指向无效的变量。
- 富的类型是字符指针的变量。
- 铸造栏到的char ** 读变量栏并获取型指针无效的值。然后,该值被转换成类型的值指向字符指针。
- 取消引用该值产生的类型字符指针的变量。
- 该变量的值就是取出,并将其值赋给变量富。
- bar is a variable of type "pointer to void".
- foo is a variable of type "pointer to char".
- casting bar to char** reads the variable bar and fetches a value of type "pointer to void". That value is then converted into a value of type "pointer to pointer to char".
- Dereferencing that value produces a variable of type "pointer to char".
- The value of that variable is then fetched, and the value is assigned to variable foo.
请有意义吗?
更多推荐
解释指针的指针问题
发布评论