Deutsch   English   Français   Italiano  
<861puahy8h.fsf@linuxsc.com>

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

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: "array"
Date: Wed, 02 Apr 2025 17:42:22 -0700
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <861puahy8h.fsf@linuxsc.com>
References: <array-20250402114422@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Thu, 03 Apr 2025 02:42:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5fae27e4725ec0f03e8fd915a6650b3a";
	logging-data="3219972"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19MQvOoAv6bkj489I5N/Q9QqiwTege4ebM="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:LAJBvFgQ7BX6dSljb6/fDMbZWpA=
	sha1:1bVUSW+6ddgzsFjGaxSSTerbPc0=
Bytes: 2210

ram@zedat.fu-berlin.de (Stefan Ram) writes:

>   Below, an array is allocated dynamically.
>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main( void )
> { char *array_pointer = malloc( 10 * sizeof *array_pointer );
>   if( !array_pointer )return EXIT_FAILURE;
>   *array_pointer = 'a';
>   free( array_pointer ); }
>
>   But is it really an array according to the C spec?
>
>   C only defines "array type", not array, but it uses ISO/IEC 2382:2015
>   as a normative reference, and ISO/IEC 2382:2015 says:
>
> |array
> |An aggregate that is an instance of an array type and each
> |element or appropriate group of elements in which may be
> |referenced randomly and independently of the others.
> ISO/IEC 2382-15 (1998), 15.03.08 (Can't access newer versions!)
>
>   . That block of memory that malloc allocated, does it have an
>   array type?  I'm not sure.  So are we allowed to call it an array?

I'm not sure why you are having trouble answering this question.
Did you read the section in the C standard for malloc(), and also
its parent section, "Memory management functions", that applies to
all the memory allocation functions (calloc(), malloc(), realloc(),
etc).