Che*_*tah 4 c string printf pointers char
我明白&用于引用对象的地址&char* = char**.反正是有扭转,这样我可以得到char*从char**?
所以我有:
char** str; //assigned to and memory allocated somewhere
printf ("%s", str); //here I want to print the string.
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
Jac*_*kin 17
您可以使用取消引用运算符.
的引用操作符上的指针变量进行操作,并返回一个1-值等同于在指针地址的值.这称为"解除引用"指针.
char** str; //assigned to and memory allocated somewhere
printf ("%s", *str); //here I want to print the string.
Run Code Online (Sandbox Code Playgroud)
取消引用str:
print ("%s", *str); /* assuming *str is null-terminated */
Run Code Online (Sandbox Code Playgroud)