On Monday, August 03, 2015 6:41:22 PM walt wrote:
> That line declares *hostname as a constant and then the statement below
> proceeds to assign a value to the 'constant'.  I wonder how many hours
> of frustration have been suffered by student programmers while trying to
> understand the logic behind that.

Because it's not a constant, it's a pointer-to-constant :)

const char *hostname; /* pointer to constant char */
char *const hostname; /* constant pointer to char */
const char *const hostname; /* constant pointer to constant char */

Is that confusing enough?

-- 
Fernando Rodriguez

Reply via email to