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;
}
Address of i
Address of j
10
223
Error: cannot convert parameter 1 from 'const int **' to 'int **'
Garbage value
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
23 comments Page 3 of 3.

Xyz said:   1 decade ago
Please anybody explain this one.

GOPU said:   1 decade ago
Please explain this.

Shammas said:   1 decade ago
I can't understand the concept..


Post your comments here:

Your comments will be displayed after verification.