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;
}
llo
hello
ello
h
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
37 comments Page 2 of 4.

Deepika said:   9 years ago
Very well explained @Deepu.

Venky said:   9 years ago
The reference operator and the dereference operator gets cancelled. And it will print hello.

Vishal said:   1 decade ago
Thanks shamini

Atiq shaiklh said:   9 years ago
if & and * both of them come together they will cancel out and remain is *p and it will print Hello.

Irisident said:   8 years ago
Thanks @Shamini.

Rajan said:   8 years ago
*p will give run time error, p will print hello.

Amit said:   8 years ago
#include<stdio.h>

int main()
{
char *p;
p="hello";
printf("%s\n",*p);//it is not working why?
//*p means value at address

//pointer variable store the address of another variable but here hello is what.
return 0;
}

Amar dengale said:   7 years ago
Hi, I am not getting this. Explain the question.

Sakshi Munya said:   6 years ago
Very nice explanation. Thanks @Deepu.

Venkatesh said:   1 decade ago
Thanks shamini.


Post your comments here:

Your comments will be displayed after verification.