NOTE: The netcdf-hdf
mailing list is no longer active. The list archives are made available for historical reasons.
Elena Pourmal <epourmal@xxxxxxxxxxxxx> writes: > Ed, > > You have to use > H5Tset_size (typeid,H5T_VARIABLE) instead of H5Tset_size(typeid, strlen(txt)) > > Elena When I try this I get a seg fault when I reach H5Awrite... The question is, do I have to tell HDF5 the length of a string in a scalar string attribute? Thanks! Ed /* See if we can write an attribute to the root group. */ if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) ERR; if ((grpid = H5Gopen(fileid, "/")) < 0) ERR; /* Attach a text attribute with some of Hamlet's lines. */ if ((spaceid = H5Screate(H5S_SCALAR)) < 0) ERR; if ((typeid = H5Tcopy(H5T_C_S1)) < 0) ERR; if (H5Tset_size(typeid, H5T_VARIABLE) < 0) ERR; if ((attid = H5Acreate(grpid, ATT1_NAME, typeid, spaceid, H5P_DEFAULT)) < 0) ERR; if (H5Awrite(attid, typeid, txt) < 0) ERR; -- Ed Hartnett -- ed@xxxxxxxxxxxxxxxx
netcdf-hdf
archives: