Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: How to use a struct with qsort()? Date: Wed, 23 Oct 2019 05:47:07 -0700 Organization: A noiseless patient Spider Lines: 26 Message-ID: <865zkfhbn8.fsf@linuxsc.com> References: <06add10e-1e30-4741-a20c-ff56363733fe@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="09129d99e56165cafc27964696c7f4e6"; logging-data="29981"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Viw798C97dULIhF3Ia2J9ItzCfhj7ioc=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:nX207Lh1DQD1QXxOwas5xOQ9tvA= sha1:PV8sjnkpNJbaOfum88LGUPixHdA= Xref: csiph.com comp.lang.c:147173 Keith Thompson writes: > Bart writes: > >> [...] Use a typedef to give the struct its own name, so that you >> don't have to write 'struct words' everywhere, eg: >> >> typedef struct {char *word; double wordpf;} Words; >> >> Now you can write >> >> Words **wordrec = NULL; >> >> or sizeof(Words) etc. > > That's a perfectly valid choice. It has the advantage that the > name of the type is a single identifier. > > Personally, though, I prefer to refer to the type as "struct > whatever" rather than inventing a new name for it. My point of > view is that if you define a struct with a tag, it already has a > perfectly good name. [...] If a struct is defined with a tag, there is no doubt that the type already has a name. Whether that name is a perfectly good name is another question altogether.