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;
}
Discussion:
110 comments Page 5 of 11.
Hai said:
1 decade ago
Plese help me in how pointer point p with example showing ** means and ++p.
Veeraselvi said:
1 decade ago
What is the difference between *p and **p? Example c & Java program.
Any one please tel me the answer?
Any one please tel me the answer?
Suchismita said:
1 decade ago
How can we print WHITE by using s pointer?
Lakshmi said:
1 decade ago
@suchismita.
We can print white as:
printf("%s",++s);
or
Give *s as a pointer to any varibale name, you can indirectly do so
printf("%s",s+1);
Here
printf("%s",*s+1);
We can print white as:
printf("%s",++s);
or
Give *s as a pointer to any varibale name, you can indirectly do so
printf("%s",s+1);
Here
printf("%s",*s+1);
Prashant said:
1 decade ago
If I write *(*p+1) why violet is printed ?
Beauty of the nation said:
1 decade ago
Please tell me how can we analyze this description.
Nani said:
1 decade ago
Can anyone please tell me why is ++p equal to pink here?
RAHUL KUMAR said:
1 decade ago
In first line there are four character arrays
s+3 means s[3] means voilet
s+2.......etc
**p+1 will first point to s2 and in that string control will move one
String forwad and print that
i.e s[3]=pink
**p+1=ink
s+3 means s[3] means voilet
s+2.......etc
**p+1 will first point to s2 and in that string control will move one
String forwad and print that
i.e s[3]=pink
**p+1=ink
Sudhakar said:
1 decade ago
In char **ptr[] declaration why do we use double *
Even though output will be same for single *
Even though output will be same for single *
Jassi said:
1 decade ago
Why we declared p as triple pointer. And then equated it with ptr i.e. ptr=p;.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers