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 10 of 11.

Xyz said:   9 years ago
What is the output if we put %c instead of %s in printf statement?

Emanuel said:   9 years ago
I think it doesn't work.

The 1st line keeps the array of char pointers. The array of addresses of the first team of each char array, and who will keep the each char array itself?

Correct me, if I am wrong.

Emanuel said:   9 years ago
I think the name of the array is a pointer to the 1st method of the array, but when it is stated implicitly how it can be catched by a pointer to char?

SelvaKarna said:   9 years ago
How to print white?
black?
pink?

Can any one tell me?

Manish said:   9 years ago
Not getting, please explain me clearly.

Prasanth said:   8 years ago
Thank you @Radhakrishna.

Travy said:   8 years ago
Please, tell me, why we are using **p+1 in printf? What's the concept?

I know it will print ink but what's the use of using **p instead of p+1?

Here we have set p=ptr, someone please help me out.

Vasu said:   8 years ago
If we want to print **++*__p what will be the answer? Please explain it.

Danish said:   8 years ago
Best explanation, Thanks, @Piyush Prakash.

Spartacus9621 said:   8 years ago
Why we use static? Can anybody explain me the use of static?


Post your comments here:

Your comments will be displayed after verification.