Item

ArrayIns

Insert a NIL element into an array

Syntax

Signature
int ArrayIns( 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 AIns(): the elements from index move one place right and the element at index becomes NIL. The last element is released, the length does not change; ArraySize() first keeps the last element.

Example

arrayins.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" );

   ArrayIns( array, 1 );
   puts( ArrayGetCPtr( array, 2 ) );
   ItemRelease( array );

   return 0;
}

See also