C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 17)
17.
What will be the output of the program ?
#include<stdio.h>
int main()
{
char *p;
p="hello";
printf("%s\n", *&*&p);
return 0;
}
Discussion:
37 comments Page 3 of 4.
Deepak said:
1 decade ago
Thanks samini
Piyush said:
1 decade ago
Thanks shamini.
Akash said:
1 decade ago
Very nice explanation Rajesh. Its conceptual.
Ravichandra said:
1 decade ago
Thank you shamini & kaarshad both explain in their own way every one can understand.
Vishwa said:
1 decade ago
*&*&p = *(&(*(&p))) = *(&(*&p))=*(&p) = *&(p) = p
so it will print 'hello'
so it will print 'hello'
Suresh said:
1 decade ago
Hello. This is the platform for learning subject. Not for easy to remember shamini. Good try Mr. Mohd kaarshad.
Mohd kamarshad said:
1 decade ago
Because & is reference operator and * is a dereference operator
so *(&p) converted into value at the address
this processes again...
and eventually we would get output as
--> hello
so *(&p) converted into value at the address
this processes again...
and eventually we would get output as
--> hello
Venkatesh said:
1 decade ago
Thanks shamini.
Jisha said:
1 decade ago
Thanks shamini.
Manasa said:
1 decade ago
Thanks shamini I don't know how to do it your answer is easy to remember.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers