Scroll to navigation

MAT_VARSETSTRUCTFIELDBYNAME(3) Library Functions Manual MAT_VARSETSTRUCTFIELDBYNAME(3)

NAME

Mat_VarSetStructFieldByNameSets a field in a structure array.

SYNOPSIS

#include <matio.h>

matvar_t *
Mat_VarSetStructFieldByName(matvar_t *matvar, const char *field_name, size_t index, matvar_t *field);

DESCRIPTION

The () function assigns field to the structure field named field_name for the structure element at linear index in matvar.

The function requires matvar to be a structure variable created by () or (). When a field is assigned successfully, the field variable name is updated to match the structure field name.

RETURN VALUES

On success, the previous field stored at the requested structure element and field position is returned. If no previous field was set, or if matvar is not a valid structure variable, NULL is returned.

EXAMPLES

This example assigns fields in a structure array by name and by index.

matvar_t *old_field;

old_field = Mat_VarSetStructFieldByName(matvar, "field1", 0, field1);
if ( old_field != NULL )
    Mat_VarFree(old_field);

SEE ALSO

Mat_VarCreateStruct(3), Mat_VarCreateStruct2(3), Mat_VarAddStructField(3), Mat_VarSetStructFieldByIndex(3)

April 23, 2026 Nixpkgs