Path: utzoo!attcan!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!unmvax!ncar!tank!mimsy!haven!ncifcrf!nlm-mcs!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: address of structure == address of first member? (long) Message-ID: <8976@smoke.BRL.MIL> Date: 24 Nov 88 06:38:00 GMT References: <2172@iscuva.ISCS.COM> <8954@smoke.BRL.MIL> <2176@iscuva.ISCS.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 17 In article <2176@iscuva.ISCS.COM> carlp@iscuva.ISCS.COM (Carl Paukstis) writes: ->>86 code = strcmp (key, *(char **)((char *)table + (m * size))); ->Line 86 is okay, but you really don't need to cast to a (char**) then ->dereference to get the (char*) key. That's extra work that amounts to ->a no-op. - Huh? The type of the expression ((char *)table + (m * size)) is - "pointer to char", no? And the usage on line 86 requires "pointer to - pointer to char". If I dereference the subexpression above, e.g. - *((char *)table + (m * size)), the result type is "char", not "pointer - to char" as required by strcmp(). Or am I just being dense? That's not what I said! You already had a (char *). You then cast it to (char **), and then dereferenced that using the * operator. There was no need for these extra steps when the original (char *) was just what you needed. (strcmp takes (char *) arguments.)