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
why we wont use '&' sing in aceesing the string using scanf
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.
How old is c programming language?
What is the equivalent code of the following statement in WHILE LOOP format?
What does p mean in physics?
What is New modifiers?
Why is c called a mid-level programming language?
What is the use of getchar() function?
write a program to copy the string using switch case?
how many errors in c explain deply
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
What are the similarities between c and c++?
Explain how are portions of a program disabled in demo versions?
how to write optimum code to divide a 50 digit number with a 25 digit number??