Path: utzoo!attcan!uunet!husc6!rutgers!att!whuts!mjs From: mjs@whuts.ATT.COM (SCHEUTZOW) Newsgroups: comp.os.minix Subject: struct pointers Message-ID: <5092@whuts.ATT.COM> Date: 21 Nov 88 17:58:41 GMT Organization: AT&T Bell Laboratories, Whippany NJ Lines: 23 > Reply-To: katzung@laidbak.UUCP (Brian Katzung) > Another bug... > > struct { int m; } sa[1]; > (1) sa->m = 0; /* Compiler chokes on this */ > (2) (&(*sa))->m = 1; /* But this works */ > > The compiler complains about applying -> to an array. > Line (1) seems like a misuse of the pointer operator to me; I would have written: sa[0].m = 0; (After all, it was declared as an array) Line (1) makes it past the lint checker on this machine, but just because our compiler accepts it doesn't mean that all of them must. I'm tempted to ramble about pointer- to-struct and pointer-to-array-of-struct, but I'll skip it. Line (2) creates a pointer because of the "&", so using the pointer operator shouldn't cause any trouble. Mike S. att!whuts!mjs