I understand that & is used to reference the address of object so &char* = char**
. Is there anyway to reverse this so that I can get char*
from char**
?
So I have:
char** str; //assigned to and memory allocated somewhere
printf ("%s", str); //here I want to print the string.
How would I go about doing this?
You can use the dereference operator.
The dereference operator operates on a pointer variable, and returns an l-value equivalent to the value at the pointer address. This is called "dereferencing" the pointer.
char** str; //assigned to and memory allocated somewhere
printf ("%s", *str); //here I want to print the string.
Dereference str
:
print ("%s", *str); /* assuming *str is null-terminated */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With