# Making a directory in C.



## cenu (Jun 18, 2014)

I'm working on an archiving program to challenge myself. I'm still fairly early in its development, but I'd like to know how to make a new directory in C in advance so I can prepare myself for when I actually have to implement that code. I've search_ed_ for a method on Google and found mention of the mkdir() function in many Linux forums, but couldn't find it in the man 3 pages. Is it available on FreeBSD and other platforms?

Thanks in advance.


----------



## kpa (Jun 18, 2014)

It's a system call in FreeBSD so it can found in the section 2, mkdir(2). I looked up my K&R second edition that is essentially ANSI C89 and there's no mention of mkdir. Also the Linux manual page seems to be in system calls as well.

http://man7.org/linux/man-pages/man2/mkdir.2.html


----------



## obsigna (Jun 18, 2014)

I always found  the GNU manual for the Standard C Library very helpful for getting the big picture. The differences to the BSD Standard C are only minor, and mostly mentioned in said manual. For the gory details, I eventually consult the man pages. The man sections relevant for the C functions are usually 2 and 3.

mkdir(2) is explained in:
14 File System Interface
14.8 Creating Directories


----------



## wblock@ (Jun 18, 2014)

The whatis(1) command can show available man pages in more than one section:

```
% whatis mkdir
mkdir(1)                 - make directories
mkdir(2), mkdirat(2)     - make a directory file
```


----------



## sotownsend (Jun 23, 2014)

When you're writing C programs, it is useful to first check http://pubs.opengroup.org/onlinepubs/9699919799/ if you're doing something ordinary on a POSIX or semi-POSIX compliant operating system (FreeBSD, Linux, Windows, etc.). I searched 'mkdir' and it came up with the appropriate documentation and header files required (see the second entry).


----------



## cenu (Jul 3, 2014)

Thanks everyone. I think you all answered my question.


----------

