Hi Manoj,
More C++ examples will be posted. For now, please see the sample code below
for fixed-length string:
// Create a fixed-length string
StrType fls_type(0, len_of_your_attribute); // 0 is a dummy argument
// Open your group
// Create dataspace for the attribute
DataSpace att_space(H5S_SCALAR);
// Create an attribute for the group
Attribute your_attribute = your_group.createAttribute(attr_name,
fls_type, att_space);
// Write data to the attribute
your_attribute.write(fls_type, buffer_for_attribute);
You can replace the first statement with this for variable-length string
StrType vls_type(0, H5T_VARIABLE);
Binh-Minh
>-----Original Message-----
>From: [email protected] [mailto:hdf-forum-
>[email protected]] On Behalf Of Manoj Rajagopalan
>Sent: Friday, April 16, 2010 8:49 AM
>To: HDF Users Discussion List
>Subject: [Hdf-forum] C++ API: how to write string attribute?
>
>Hi all,
>
> I am new to HDF5 and am using the C++ API. I apologize for what might
>seem
>pretty basic? I am unable to write a string attribute to my Group - I can't
>seem to figure out which datatype/space to use. Could someone give me a
>hint?
>
>Thanks,
>Manoj
>
>_______________________________________________
>Hdf-forum is for HDF software users discussion.
>[email protected]
>http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
>
>
>--
>Internal Virus Database is out-of-date.
>Checked by AVG.
>Version: 7.5.549 / Virus Database: 270.9.0/1778 - Release Date: 11/9/2008
>2:14 PM
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org