C Programming - Pointers - Discussion

Discussion Forum : Pointers - Find Output of Program (Q.No. 1)
1.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    static char *s[] = {"black", "white", "pink", "violet"};
    char **ptr[] = {s+3, s+2, s+1, s}, ***p;
    p = ptr;
    ++p;
    printf("%s", **p+1);
    return 0;
}
ink
ack
ite
let
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
110 comments Page 6 of 11.

Divya said:   1 decade ago
@saravanan
***pointer points to third string in the array
whereas ***pointer+1 indicates the third string from 2nd letter

Vishal said:   1 decade ago
If we will take *--*++p+3 in place of **p+1 then ck from black is printed as o/p but why ?

Any one can tell me dis.

Prem said:   1 decade ago
Hi, @Manali.

*k = value at the address contained in k.
**k = value at the address contained in *k.

And so on...

Anitha said:   8 years ago
find the output
int s[]='hold';
*s='C';
print f("%s",s);


Can anyone please answer this question?

Soujanya ,ravali said:   1 decade ago
If in the above program instead of **p+1 if it is *--*++p+3 is given

What is the output? Give explanation.

Veeraselvi said:   1 decade ago
What is the difference between *p and **p? Example c & Java program.

Any one please tel me the answer?

Nagesh said:   1 decade ago
@Manali,

See below:
*K - Value at K.
**K - Value at *K.
**K - Value at **K.

Still confusing dear ?

Sudhakar said:   1 decade ago
In char **ptr[] declaration why do we use double *
Even though output will be same for single *

U Naveena Reddy said:   1 decade ago
What is the use of ** (double star) , *** (triple stars) , if you don't mind, please explain me?

Prakash said:   1 decade ago
To access the elements efficiently in different methodologies and execution speed is faster.


Post your comments here:

Your comments will be displayed after verification.