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;
}
Discussion:
69 comments Page 4 of 7.
Divyaa said:
8 years ago
What will be the answer if the given question is;
Char *p =0;*p='a';
Printf("value of pinter p in %c",*p);
Please explain it.
Char *p =0;*p='a';
Printf("value of pinter p in %c",*p);
Please explain it.
Cp ahirwar said:
8 years ago
Statement 1: char *a="Hello" represents a pointer to constant string.
Statement 2: char a[]="Hello" represents constant pointer to a string.
Statement 2: char a[]="Hello" represents constant pointer to a string.
Akshay said:
7 years ago
Good explanation @Biswajit.
Riyaz said:
7 years ago
Thanks for all your explanation.
Deepika said:
6 years ago
The First position of array is replaced by M so it prints "Mello".
Vinoth said:
1 decade ago
Thanks all of them
Saurav said:
1 decade ago
P is const how can we change it?
Pruthvi said:
1 decade ago
If p is a pointer to a character constant then how can the character constant value can be changed?
Rocketraja said:
1 decade ago
Can you explain still more clearly?
Saroj said:
1 decade ago
If we declare the constant pointer then already declared place is in array a[size], what ever we declare that place depends on the size it should changed.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers