wats the diference btwen constant pointer and pointer to a
constant.pls give examples.
Answer Posted / satyajit nayak
Hello All,
AS name suggested things are very simple.
1.Constant pointer
======================
it's nothing but a
(i)pointer which is pointing to a constant memory
location.
(ii)Once this pointer is assigned to point some location
we cann't make it to locate some other address location.
(iii)So constant pointer should be initialized at the
point of declaration only.
Example
=========
1. int main()
{
int * const my_ptr; //now my_ptr point to garbage
location
int var=10;
my_ptr=&var; //trying to modify my_ptr location.so
gives ERROR
}
so correct way of assignment is like
int main()
{
int var=10;
int * const my_ptr=&var;
printf("Addr=%x,val=%d",my_ptr,*my_ptr);
}
Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none
What do you mean by a local block?
What is void pointers in c?
What is a scope resolution operator in c?
In c programming language, how many parameters can be passed to a function ?
Why is python slower than c?
Explain what is the best way to comment out a section of code that contains comments?
What is an lvalue in c?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
Why is C language being considered a middle level language?
Dont ansi function prototypes render lint obsolete?
Was 2000 a leap year?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
What is meant by inheritance?