J
Jess
Hello,
If I have a constant array, i.e. it's elements aren't changed, should
I declare it as:
const int a[] = {1,2,3};
or
int const a[] = {1,2,3}
For this simple problem, perhaps it doesn't matter. However, if I
have an array of pointers (e.g. array of strings), then I think there
are several ways to write with "const", but with different meanings:
(1). const char* const b[]
(2). char* const b[]
(3). const char* b[]
I think the first one means "b" is an array of pointers, each pointer
is pointing to a fixed (unchangable) address. Then for the "const
char*", does it mean the pointer is pointed to one single fixed char?
or, does it mean it points to an array of fixed chars (i.e. none of
the char is changable)?
The second and the third one are even more confusing. For example,
does the "const" in (2) mean the pointers pointing to fixed addresses,
or, the values pointed to are fixed?
Thanks a lot.
If I have a constant array, i.e. it's elements aren't changed, should
I declare it as:
const int a[] = {1,2,3};
or
int const a[] = {1,2,3}
For this simple problem, perhaps it doesn't matter. However, if I
have an array of pointers (e.g. array of strings), then I think there
are several ways to write with "const", but with different meanings:
(1). const char* const b[]
(2). char* const b[]
(3). const char* b[]
I think the first one means "b" is an array of pointers, each pointer
is pointing to a fixed (unchangable) address. Then for the "const
char*", does it mean the pointer is pointed to one single fixed char?
or, does it mean it points to an array of fixed chars (i.e. none of
the char is changable)?
The second and the third one are even more confusing. For example,
does the "const" in (2) mean the pointers pointing to fixed addresses,
or, the values pointed to are fixed?
Thanks a lot.