1 |
On Monday, August 03, 2015 6:41:22 PM walt wrote: |
2 |
> That line declares *hostname as a constant and then the statement below |
3 |
> proceeds to assign a value to the 'constant'. I wonder how many hours |
4 |
> of frustration have been suffered by student programmers while trying to |
5 |
> understand the logic behind that. |
6 |
|
7 |
Because it's not a constant, it's a pointer-to-constant :) |
8 |
|
9 |
const char *hostname; /* pointer to constant char */ |
10 |
char *const hostname; /* constant pointer to char */ |
11 |
const char *const hostname; /* constant pointer to constant char */ |
12 |
|
13 |
Is that confusing enough? |
14 |
|
15 |
-- |
16 |
Fernando Rodriguez |