Hi Branden, G. Branden Robinson wrote on Sat, May 05, 2018 at 05:20:19PM -0400: > At 2018-05-05T20:05:20+0200, Ingo Schwarze wrote:
>> P.S. >> By the way, using "char const" doesn't make understanding >> >> char *const *evil[2][3]; >> >> any easier for people who do not know the rules... > This looks like a wonderful opportunity to embarrass myself. > > "evil" is a pointer to a 2x3 array of immutable pointers to strings. > > Right? Almost. If you call char ca[]; /* an array of characters */ char *s; /* a string */ char const *sc; /* an immutable string */ char **sp; /* a pointer to a string */ char const **scp; /* a pointer to an immutable string */ char **const spc; /* an immutable pointer of to a string */ char *sa[]; /* an array of strings */ int *const ipc; /* an immutable pointer to an integer */ char *const cpc; /* an immutable pointer to a character */ int (*iap)[]; /* a pointer to an array of integers */ then char *const *my_evil[2][3]; is a 2x3 array of pointers to immutable pointers to characters. What you described as a pointer to a 2x3 array of immutable pointers to strings might be char **const (*gbrs_evil)[2][3] But as i said, it is evil, so maybe i'm wrong, too. My point wasn't what such evil things mean (even though i admit to the sin of writing "const char **arches[] = {..." in mandoc), but merely that "char const = const char" is *not* what is causing the real difficulty here, but merely a minor, trivial curiosity near the sideline. I guess that came across now. :) I most emphatically agree that both the concept of C pointers, strings, and arrays, as well as their syntax, are hard to master even for seasoned C programmers, an abundant nest of bugs, and often enough leave me bewildered, too. Add the sizeof() operator to the mix and brace yourself for chaos. What is sizeof(my_evil), sizeof(*my_evil), sizeof(gbrs_evil), and sizeof(*gbrs_evil)? That particular syntax possibly isn't K&R&T's most outstanding achievement... Now we are definitely off topic. SCNR. Yours, Ingo