/************************************************************ This example shows how to read and write variable-length datatypes to an attribute. The program first writes two variable-length integer arrays to the attribute then closes the file. Next, it reopens the file, reads back the data, and outputs it to the screen. This file is intended for use with HDF5 Library version 1.6 ************************************************************/ #include "hdf5.h" #include #include #define FILE "h5ex_t_vlenatt.h5" #define DATASET "DS1" #define ATTRIBUTE "A1" #define LEN0 3 #define LEN1 12 int main (void) { hid_t file, filetype, memtype, space, dset, attr; /* Handles */ herr_t status; hvl_t wdata[2], /* Array of vlen structures */ *rdata; /* Pointer to vlen structures */ hsize_t dims[1] = {2}; int *ptr, ndims, i, j; /* * Initialize variable-length data. wdata[0] is a countdown of * length LEN0, wdata[1] is a Fibonacci sequence of length LEN1. */ wdata[0].len = LEN0; ptr = (int *) malloc (wdata[0].len * sizeof (int)); for (i=0; i