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
Is main a keyword in c?
#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }
What is double pointer?
How many keywords are there in c?
Why should I prototype a function?
Explain pointer. What are function pointers in C?
What library is sizeof in c?
How are pointers declared in c?
What is the equivalent code of the following statement in WHILE LOOP format?
we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?
What is static identifier?
What does & mean in scanf?
Tell me can the size of an array be declared at runtime?
Why is c called c not d or e?
Is it valid to address one element beyond the end of an array?