summaryrefslogtreecommitdiffstats
path: root/HDF5Examples/C/H5G/h5ex_g_create.c
diff options
context:
space:
mode:
Diffstat (limited to 'HDF5Examples/C/H5G/h5ex_g_create.c')
-rw-r--r--HDF5Examples/C/H5G/h5ex_g_create.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/HDF5Examples/C/H5G/h5ex_g_create.c b/HDF5Examples/C/H5G/h5ex_g_create.c
new file mode 100644
index 0000000..d7bb156
--- /dev/null
+++ b/HDF5Examples/C/H5G/h5ex_g_create.c
@@ -0,0 +1,45 @@
+/************************************************************
+
+ This example shows how to create, open, and close a group.
+
+ This file is intended for use with HDF5 Library version 1.8
+
+ ************************************************************/
+
+#include "hdf5.h"
+
+#define FILE "h5ex_g_create.h5"
+
+int
+main(void)
+{
+ hid_t file = H5I_INVALID_HID;
+ hid_t group = H5I_INVALID_HID;
+ herr_t status;
+
+ /*
+ * Create a new file using the default properties.
+ */
+ file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Create a group named "G1" in the file.
+ */
+ group = H5Gcreate(file, "/G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Close the group. The handle "group" can no longer be used.
+ */
+ status = H5Gclose(group);
+
+ /*
+ * Re-open the group, obtaining a new handle.
+ */
+ group = H5Gopen(file, "/G1", H5P_DEFAULT);
+
+ /*
+ * Close and release resources.
+ */
+ status = H5Gclose(group);
+ status = H5Fclose(file);
+}