Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: David Brown Newsgroups: comp.lang.c Subject: Re: Regarding assignment to struct Date: Tue, 6 May 2025 11:46:21 +0200 Organization: A noiseless patient Spider Lines: 27 Message-ID: References: <877c2uhj9l.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 06 May 2025 11:46:22 +0200 (CEST) Injection-Info: dont-email.me; posting-host="0cd47886b7e303493d192d1a16d3f773"; logging-data="2796276"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bIyUXVNASzlAcv9OL0irIDqipP9BT5jQ=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:F/KDvCCcUZv1aFmkVql0LdZK0DY= In-Reply-To: <877c2uhj9l.fsf@nosuchdomain.example.com> Content-Language: en-GB On 05/05/2025 22:53, Keith Thompson wrote: > Muttley@dastardlyhq.com writes: > [...] >> If you twant o pass an actual array to a function instead of a pointer to it, >> embedding it in a structure is the only way to do it. > > Yes, but that's not necessarily useful. An array that's a member > of a struct can only be of a constant length (unless it's a flexible > array member, but that doesn't help). Functions that work with > arrays typically need to deal with arrays of arbitrary length. > I regularly use arrays with known fixed sizes. In fact, in my code those are absolutely dominant - it is very rare for me to see or use an array whose size is /not/ fixed at compile time. Sometimes I will have general functions that take parameters that are arrays of arbitrary length, but not often. So this is very much dependent on the kind of code you are working with, and other people will have very different experiences for their own code. However, I think it is not unlikely that people will see use of structs like : struct vector4int { int vs[4]; };