2. Embedded QUEL for C : C Variables and Data Types : Variable Usage : Pointer Variables
 
Share this page                  
Pointer Variables
The following syntax refers to a pointer variable:
*{*}pointername
Syntax Notes:
Refer to the variable indirectly, because only scalar-valued elements (integers, floating-point and character strings) are legal QUEL values.
When the variable is declared, the preprocessor notes the number of preceding asterisks. Later references to the variable must have the same indirection level. The indirection level is the sum of the number of pointer operators (asterisks) preceding the variable declaration name and the number of array subscripts following the name.
A character string, declared as a pointer to a character, is not considered a pointer and cannot be subscripted in order to reference a single character. As with arrays, single characters are illegal string values, because any character string value must be null-terminated. For example, assuming the following declaration:
## char *abc = "abc";
you could not access the character "a" with the reference:
*abc
When you declare external compiled forms:
UNIX:
extern int *compiled_formname; 
VMS:
globalref int*compiled_formname
do not include any indirection when referenced in the addform statement.
As with standard C, any variable that you denote with pointer indirection can also be denoted with array subscripting. This is true because the preprocessor only records the number of indirection levels used when referencing a variable. For example, if a variable is declared as a pointer:
int *age_pointer;
it can be referenced as either a pointer:
*age_pointer;
or an array:
age_pointer[0];
If you use the pointer variant, you must verify that the pointer does not immediately follow a left parenthesis without a separating space, as "(*" is a reserved operator. For example:
##    retrieve   (*age_pointer = e.age )
Note the space between the "(" and the "*."
The following example uses a pointer to insert integer values into a database table:
##      int *numptr;
##      static int numarr[6] = {1, 2, 3, 4, 5, 0};

        for (numptr = numarr; *numptr; numptr++)
##            append items (number = *numptr)
For information on pointers to structures and members of structures, see Structure Variables (see Structure Variables).