Item

ArrayDel

Delete an array element

Syntax

Signature
int ArrayDel( ITEM *array, size_t index );

Arguments

array Array to access.

index Element position, counted from 1.

Return value

1; 0 when index is 0 or greater than the length of the array.

Description

As ADel(): the element at index is released, the elements after it move one place left and the last one becomes NIL. The length does not change; ArraySize() shortens the array.

Example

arraydel.c
#include "xdev-wtui.h"

#include <stdio.h>

int main( void )
{
   ITEM *array = Array( 2 );

   if( !array )
      return 1;

   ArraySetC( array, 1, "First" );
   ArraySetC( array, 2, "Second" );

   ArrayDel( array, 1 );
   puts( ArrayGetCPtr( array, 1 ) );
   ItemRelease( array );

   return 0;
}

See also