Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Sort char array Date: Sat, 19 Oct 2019 13:13:45 -0700 Organization: None to speak of Lines: 43 Message-ID: References: <20191010003208.ff29e87d2de1e17c50f96c74@gmail.com> <20191013213743.84c68aaf89bc1cd6b995db5b@gmail.com> <20191014005637.56bd13f20bceb6f3c4233b09@gmail.com> <20191014133326.cc63c82d5be1aad83f49d6ff@g{oogle}mail.com> <87h8462h3z.fsf@bsb.me.uk> <5vDqF.1358676$i14.425769@fx27.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="6afd8787b1900bf8ee99262564b7b486"; logging-data="29399"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+81bB2wpRzuRnq56MiY1q6" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:cqjgIcDuhQuwfJ4IvVCIKyCcBNI= sha1:a1XiJd4T4JBQHIL+82X9mhfR5AE= Xref: csiph.com comp.lang.c:147088 Bart writes: > On 19/10/2019 12:24, David Brown wrote: >> On 19/10/2019 00:06, Bart wrote: >>> http://www.ti.com/lit/an/spraao8/spraao8.pdf >>> >>> Notice the type of most fields is one of Char, Short, and Long, used >>> for fields of 1, 2 and 4 bytes, which are begging to be represented in >>> a C struct as char, short and long. >> >> Sometimes the field types are called "Character" or "Integer" too. > > Character is used for short character arrays. Integer for 4-byte signed > integers, the same as Long. It's not clear why one such field is > Integer, and the other Long. The type name "Integer" is used in only one table, "File Header Contents". All the other layout tables consistently use "Short" or "Unsigned short" for 2-byte fields, and "Long" or "Unsigned long" for 4-byte fields, with footnotes saying "For C6000 the type is integer". Note that C has no type named "Integer" or "integer". The document doesn't refer to C types. The tables show the byte range for each field, so the sizes are unambiguous. The fact that this particular document was sloppily written says nothing about C. You cannot portably define a C structure that exactly matches the 22-byte layout of the file header, for example (2 16-bit unsigned integers, 3 32-bit signed integers, 3 16-bit unsigned integers). That doesn't make it particularly difficult to write C code that deals with files containing such headers. You just have to be able to figure out that "Unsigned long" doesn't necessarily refer to C's "unsigned long" type. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */