C Programming - Pointers - Discussion

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

int main()
{
    char str[20] = "Hello";
    char *const p=str;
    *p='M';
    printf("%s\n", str);
    return 0;
}
Mello
Hello
HMello
MHello
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
69 comments Page 7 of 7.

Red said:   1 decade ago
Why is 'M' given? shouldn't it be "M"?

Pk123 said:   1 decade ago
Can any one explain char const line?

Rocketraja said:   1 decade ago
Can you explain still more clearly?

Solomon said:   1 decade ago
Thank you all fr your explanation.

Riyaz said:   7 years ago
Thanks for all your explanation.

Saurav said:   1 decade ago
P is const how can we change it?

Akshay said:   7 years ago
Good explanation @Biswajit.

Venky said:   1 decade ago
@Nithya.

Str[1] = 'M'.

Vinoth said:   1 decade ago
Thanks all of them


Post your comments here:

Your comments will be displayed after verification.