Shiny Language Reference

Language Reference > Basic Language


getalloc

int getalloc(varname);

 

Synonyms:

int getarraysize(varname);

int sizeof(varname);

 

Returns the size (number of elements) of an array

The GETALLOC statement returns the number of elements an array currently has allocated. C/C++ coders note the semantic difference between the C sizeof and the Shiny sizeof.

 

Parameters

Varname

The variable, declared as an array, to return the size of.

 

Return Value

The number of elements the array has allocated.

 

Example Code

// Declare an array with 5 elements
int test[5];

// Prints "Array elements: 5"
print "Array elements: " + getalloc(test);

// Reduce the array to only hold 3 elements
realloc(test, 3);

// Prints "Array elements: 3"
print "Array elements: " + getalloc(test);