char *sample = "String Value";
&sample is a pointer to the pointer of "String Value"
is the above statement right?
If the above statement right, what is the equivalent of &sample if my declaration is
char sample[] = "String Value"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In the first one, there are two objects being created.
One is a
char *(pointer-to-char) calledsample, and the other is an unnamed array of 13 chars containing the characters of the string. In this case,&samplegives the address of the objectsample, which is the address of a pointer-to-char – so, a pointer-to-pointer-to-char.In the second example, there’s only one object being created; an array of 13 chars called
sample, initialised with the characters of the string. In this case,&samplegives the address of the objectsample– so, a pointer-to-array-of-13-chars.In the second example, there is no “equivalent” to
&samplein the first example, in the sense of a pointer-to-pointer-to-char value. This is because there is no pointer-to-char value to take the address of. There is only the array.