Created
February 2, 2016 21:03
-
-
Save Dr-ZeeD/5f9e5a3e9eafe3faef9a to your computer and use it in GitHub Desktop.
How to create an empty HDF5 file using the C API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This file demonstrates how to create an empty HDF5 file using the C API. | |
| // If you happen to have HDF5 installed using MacPorts you can compile the | |
| // exmaple using | |
| // | |
| // gcc -I/opt/local/include HDF5_create_file.c -L/opt/local/lib -lhdf5 -o HDF5_create_file | |
| // | |
| // 2016, Dominik Steinberger | |
| #include "hdf5.h" | |
| int main() { | |
| // First an empty file is created using H5Fcreate. It returns a file handle | |
| // that is of the type ``hid_t``. For the meaning of the arguments take a | |
| // look at https://www.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-Create | |
| hid_t file_id = H5Fcreate("file.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); | |
| // In the end the file always has to be closed. This is done via H5Fclose. | |
| // It returns a status code of type ``herr_t``, that tells you if | |
| // everything went fine while closing the file or something went wrong. | |
| // To see which status means what see | |
| // https://www.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-Close | |
| herr_t status = H5Fclose(file_id); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment