there are three things
pointer to constant - the pointer directs to a constant value
const int *x = 5;
*x = 6;\\invalid
constant pointer - pointer direction cannot be changed
int const * x = 6;
x = 7; or x = &i; \\is invalid
constant pointer to constant
mix of two above
2006-07-31 21:21:13
·
answer #1
·
answered by Manpreet S 1
·
0⤊
1⤋
Fig: Can be modified (Y/N)?
const char* :: Pointer(Y) Memory(N)
char *const :: Pointer(N) Memory(Y)
const char *const :: Pointer(N) Memory(N)
Read the declarations inside out. For eg.
const char *p; // p is a pointer to const char
char *const p; // p is a const pointer to char
const char *const p; // p is a const pointer to a const char
---
char nc_hello[] = { 'h', 'e', 'l', 'l', 'o' }; // non const hello
const char *c_hello = "hello"; // const hello
case 1:
const char *p_c_hello = c_hello; // valid
const char *p_nc_hello = nc_hello; // valid
p_c_hello[0] = 'H'; // Invalid; cannot use pointer to modify memory
p_nc_hello[0] = 'H'; // Invalid
p_c_hello = p_nc_hello; // Valid; can change the pointer
2006-08-01 00:00:40
·
answer #2
·
answered by swami060 3
·
0⤊
0⤋
Arrays are blocks of memory that contain some consistent variety of records factors of an identical variety, kept contiguously. guidelines contain the memory area of an ideas ingredient. guidelines ought to easily include NULL (0) and element to no longer something, or ought to aspect to an ingredient that ought to were freed (a hanging pointer), or ought to easily aspect to random factors of memory (probable with suggestions from technique of pointer mathematics). guidelines are one mechanism for effectively walking by using arrays.
2016-11-27 05:31:06
·
answer #3
·
answered by peirson 4
·
0⤊
0⤋
you mean a pointer to a constant value?
like const int* x = 30;
more details please
2006-07-31 21:16:03
·
answer #4
·
answered by Anonymous
·
0⤊
0⤋