int mkdir (const char *filename, mode_t mode)
#include <sys/types.h>
#include <errno.h>
#include <string.h>
if (mkdir("/some/directory", S_IRWXU | S_IRWXG | S_IRWXO) == -1) {
printf("Error: %s\n", strerror(errno));
}
For best practice it is recommended to use an integer-alias for mode. The argument mode specifies the file permissions for the new directory.
Read + Write + Execute: S_IRWXU (User), S_IRWXG (Group), S_IRWXO (Others)
Source:
https://www.gnu.org/software/libc/manual/html_node/Permission-Bits.html
If you want to know that the directory exists, lookup the errno's for EEXIST.