C语言 C中的char **是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13353807/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is char ** in C?
提问by mccormickt12
Possible Duplicate:
What is double star?
可能的重复:
什么是双星?
I am fairly new to C, and have come across this statement
我对 C 相当陌生,并且遇到过这个语句
typedef char **TreeType
I have a pretty good idea of what typedef does, but I have never seen char** before. I know that char* is a char array or similiar to a string. Im not sure if char** is a 2d char array or if it is the pointer to a character array. I have looked around but cannot find what it is. If you could please explain what a char** is or point me in the right direction it would be very much appreciated.
我很清楚 typedef 的作用,但我以前从未见过 char**。我知道 char* 是一个字符数组或类似于字符串。我不确定 char** 是二维字符数组还是指向字符数组的指针。我环顾四周,但找不到它是什么。如果您能解释什么是 char** 或为我指明正确的方向,我们将不胜感激。
Thanks! :)
谢谢!:)
回答by tdk001
Technically, the char*is not an array, but a pointer to a char.
从技术上讲, thechar*不是数组,而是指向 a 的指针char。
Similarly, char**is a pointer to a char*. Making it a pointer to a pointer to a char.
同样,char**是指向 a 的指针char*。使其成为指向 a 的指针的指针char。
C and C++ both define arrays behind-the-scenes as pointer types, so yes, this structure, in all likelihood, is array of arrays of chars, or an array of strings.
C 和 C++ 都在幕后将数组定义为指针类型,所以是的,这个结构很可能是chars 数组或字符串数组。
回答by kevintodisco
It is a pointer to a pointer, so yes, in a way it's a 2D character array. In the same way that a char*could indicate an array of chars, a char**could indicate that it points to and array of char*s.
它是一个指向指针的指针,所以是的,在某种程度上它是一个二维字符数组。与 achar*可以指示chars数组相同,achar**可以指示它指向char*s数组。
回答by iceout
well, char *means a pointer point to char, it is different from char array.
好吧,char *意味着指向char的指针,它不同于char数组。
char amessage[] = "this is an array"; /* define an array*/
char *pmessage = "this is a pointer"; /* define a pointer*/
And, char **means a pointer point to a char pointer.
并且,char **表示指向字符指针的指针。
You can look some books about details about pointer and array.
您可以查看一些有关指针和数组的详细信息的书籍。

