2008 Unidata NetCDF Workshop for Developers and Data Providers > Using Groups and the New NetCDF-4 Atomic Types
15.8 Example Creating an Array of Strings
This example writes an array of strings as an attribute.
int ncid;
char *data[DIM_LEN] = {"Let but your honour know",
"Whom I believe to be most strait in virtue",
"That, in the working of your own affections",
"Had time cohered with place or place with wishing",
"Or that the resolute acting of your blood",
"Could have attain'd the effect of your own purpose",
"Whether you had not sometime in your life",
"Err'd in this point which now you censure him",
"And pull'd the law upon you."};
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_put_att(ncid, NC_GLOBAL, ATT_NAME, NC_STRING, DIM_LEN, data)) ERR;
if (nc_close(ncid)) ERR;
2008 Unidata NetCDF Workshop for Developers and Data Providers > Using Groups and the New NetCDF-4 Atomic Types