wats the diference btwen constant pointer and pointer to a
constant.pls give examples.
Answer Posted / monika sethi
CONSTANT POINTER: A pointer will always point to one
object.it is initialized at the time of declaration.
e.g
int i=20,j;
int* const p=&i;
cout<<*p; //will print 20
*p=30;//works....i.e the value pointed by the constant
pointer can be changed
//now if write
p=&j;//error
POINTER TO CONSTANT
it can be declared as
const int *p;
or
int const *p;
int i=10,j=30;
p=&i;
cout<<*p;
*p=10//error...the value is constant pointed by p
//pointer p is not constant so it can now point to another
variable of integer type
//so if we write
p=&j //it will now point to a variable j
that's all.........
| Is This Answer Correct ? | 27 Yes | 0 No |
Post New Answer View All Answers
Can i use “int” data type to store the value 32768? Why?
What is a file descriptor in c?
Write a progarm to find the length of string using switch case?
What is the difference between NULL and NUL?
Wt are the Buses in C Language
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
What are lookup tables in c?
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
Tell us bitwise shift operators?
What is an array? What the different types of arrays in c?
Explain what is a 'locale'?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
Can you write a programmer for FACTORIAL using recursion?
I have seen function declarations that look like this
Explain modulus operator.