Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Lew Pitcher Newsgroups: comp.lang.c Subject: Regarding assignment to struct Date: Fri, 2 May 2025 18:34:52 -0000 (UTC) Organization: A noiseless patient Spider Lines: 31 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 02 May 2025 20:34:52 +0200 (CEST) Injection-Info: dont-email.me; posting-host="ab988014e28279ea3266b65625913a1a"; logging-data="1270102"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9L8o5ELNpbZWGcQJiOeAlIxQQNv8GNYU=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:8RMldeRCIN6SfAEljjdaHVCvQc0= Bytes: 1907 Back in the days of K&R, Kernighan and Ritchie published an addendum to the "C Reference Manual" titled "Recent Changes to C" (November 1978) in which they detailed some differences in the C language post "The C Programming Language". The first difference they noted was that "Structures may be assigned, passed as arguments to functions, and returned by functions." From what I can see of the ISO C standards, the current C language has kept these these features. However, I don't see many C projects using them. I have a project in which these capabilities might come in handy; has anyone had experience with assigning to structures, passing them as arguments to functions, and/or having a function return a structure? Would code like struct ab { int a; char *b; } result, function(void); if ((result = function()).a == 10) puts(result.b); be understandable, or even legal? -- Lew Pitcher "In Skills We Trust"