Scroll to navigation

MAT_VARGETSTRUCTFIELD(3) Library Functions Manual MAT_VARGETSTRUCTFIELD(3)

NAME

Mat_VarGetStructFieldGets a field from a structure array.

SYNOPSIS

#include <matio.h>

matvar_t *
Mat_VarGetStructField(const matvar_t *matvar, void *name_or_index, int opt, int index);

DESCRIPTION

The () function returns a pointer to a field of the structure variable matvar for the structure element at linear index index. If opt is MAT_BY_NAME, then name_or_index must point to a field name string. If opt is MAT_BY_INDEX, then name_or_index must point to an integer containing the 1-relative field index.

The function requires matvar to be a valid structure or object variable.

RETURN VALUES

On success, a pointer to the requested field is returned. Otherwise NULL is returned.

EXAMPLES

This example gets a structure field by name and by index.

int field_index = 2;
matvar_t *field;

field = Mat_VarGetStructField(matvar, "field1", MAT_BY_NAME, 0);
field = Mat_VarGetStructField(matvar, &field_index, MAT_BY_INDEX, 0);

SEE ALSO

Mat_VarGetStructFieldByIndex(3), Mat_VarGetStructFieldByName(3), Mat_VarGetStructFieldnames(3), Mat_VarGetNumberOfFields(3)

April 23, 2026 Nixpkgs