C Programming - Const - Discussion
Discussion Forum : Const - Find Output of Program (Q.No. 3)
3.
What will be the output of the program?
#include<stdio.h>
int fun(int **ptr);
int main()
{
int i=10;
const int *ptr = &i;
fun(&ptr);
return 0;
}
int fun(int **ptr)
{
int j = 223;
int *temp = &j;
printf("Before changing ptr = %5x\n", *ptr);
const *ptr = temp;
printf("After changing ptr = %5x\n", *ptr);
return 0;
}
Discussion:
23 comments Page 2 of 3.
Arshita said:
9 years ago
How will the result come as ptr=29ff0c ptr=29fed8 how it comes?
Can anyone explain me?
Can anyone explain me?
Ranjit said:
1 decade ago
Ravi already said it.
Ptr is a const pointer. The argument of fun should be const too.
Ptr is a const pointer. The argument of fun should be const too.
Uma said:
8 years ago
Can anyone tell what does this **ptr here?
Does this tell the address of address?
Does this tell the address of address?
Siva said:
9 years ago
Can anyone explain to me?
How will the result come ptr=29ff0c ptr=29fed8?
How will the result come ptr=29ff0c ptr=29fed8?
Bond said:
1 decade ago
The ptr is declared twice in the function. How come that is not an error?
Babu said:
8 years ago
What is the meaning of %5x ? what type of format specifier is this?
Kavya said:
9 years ago
How to rectify the error? Anyone help me.
Xyz said:
1 decade ago
Please anybody explain this one.
Shammas said:
1 decade ago
I can't understand the concept..
Shru said:
1 decade ago
Ravi explanation is correct.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers