Item

ArrayGetCPtr

Return the text of an array element

Syntax

Signature
const char *ArrayGetCPtr( const ITEM *array, size_t index );

Arguments

array Array to access.

index Element position, counted from 1.

Return value

A pointer to the string, an empty string for an existing non-string element, or NULL if the slot does not exist.

Description

Uses storage owned by the array element. Copy the text before modifying or releasing the element if you need the string later.

Example

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

#include <stdio.h>

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

   if( !array )
      return 1;

   ArraySetC( array, 1, "Open" );
   printf( "%s\n", ArrayGetCPtr( array, 1 ) );
   ItemRelease( array );

   return 0;
}