Deutsch   English   Français   Italiano  
<v9puic$1s7lo$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: =?UTF-8?Q?Re=3A_technology_discussion_=E2=86=92_does_the_world_need?=
 =?UTF-8?B?IGEgIm5ldyIgQyA/?=
Date: Sat, 17 Aug 2024 11:38:05 +0100
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <v9puic$1s7lo$2@dont-email.me>
References: <v66eci$2qeee$1@dont-email.me> <20240711115418.00001cdf@yahoo.com>
 <v6oamt$2d8nn$1@dont-email.me> <v6oct4$2djgq$2@dont-email.me>
 <v6of96$2ekb0$1@dont-email.me> <v6ovfc$2hcpf$1@dont-email.me>
 <v6p4hf$2icph$1@dont-email.me> <v6qgpu$2t6p7$3@dont-email.me>
 <v6r33m$30grj$1@dont-email.me> <20240712154252.00005c2f@yahoo.com>
 <86o7717jj1.fsf@linuxsc.com> <v6ti10$3gru4$1@dont-email.me>
 <v78af7$1qkuf$1@dont-email.me> <20240717163457.000067bb@yahoo.com>
 <v78piu$1su4u$1@dont-email.me> <86a5hep45h.fsf@linuxsc.com>
 <v9ktep$v5sk$1@dont-email.me> <87y14xsvnh.fsf@bsb.me.uk>
 <v9l95b$10ogv$1@dont-email.me> <87sev5s51s.fsf@bsb.me.uk>
 <v9n6uj$1cvvg$2@dont-email.me> <87jzgge4hd.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 17 Aug 2024 12:38:04 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2b4731a8bc26cc69ac4ef4f27bf4b89c";
	logging-data="1973944"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/ayVW/OGdaRVLJT6Ll9/Qc"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:m7L1ARgWRXVhuPrdtDPn3ZyLgN8=
Content-Language: en-GB
In-Reply-To: <87jzgge4hd.fsf@nosuchdomain.example.com>
Bytes: 2614

On 16/08/2024 18:56, Keith Thompson wrote:
> David Brown <david.brown@hesbynett.no> writes:
> [...]
>> In C++, you can't pass arrays as parameters at all - the language
>> inherited C's handling of arrays.  You can, of course, pass objects of
>> std::array<> type by value or by reference, just like any other class
>> types.
> 
> #include <cassert>
> 
> typedef int array42[42];
> 
> void func(array42& param) {
>      assert(sizeof param == 42 * sizeof(int));
> }
> 
> int main() {
>      array42 arg = { };
>      func(arg);
> }

This works in C too. You don't need by-reference parameters, but you do 
need to switch sizeof to work directly on the type:


  #include <assert.h>

  typedef int array42[42];

  void func(array42 param) {
      assert(sizeof(array42) == 42 * sizeof(int));
  }

  int main() {
      array42 arg = {0};
      func(arg);
  }