Name
mkdir - Creates a directory.
Syntax
#include <direct.h>
int mkdir(path)
char *path;
Description
The mkdir function creates a new directory with the
specified path. Only one directory can be created at a time,
so only the last component of path can name a new directory.
The mkdir function does not do any translation of path-name
delimiters. Both DOS and OS/2 accept either ``\'' or ``/''
as valid delimiters within path names.
Return Value
The mkdir function returns the value 0 if the new directory
was created. A return value of -1 indicates an error, and
errno is set to one of the following values:
Value Meaning
EACCES Directory not created.
The given name is the
name of an existing
file, directory, or
device.
ENOENT Path name not found.
See Also
chdir(DOS), rmdir(DOS)
Example
#include <direct.h>
main()
{
int result;
result = mkdir("b:\\tmp");
if (result == 0)
printf("Directory 'b:\\tmp' successfully
created\n");
else
printf("Problem creating directory
'b:\\tmp'\n");
result = mkdir("tmp\\sub");
if (result == 0)
printf("Directory 'tmp\\sub' successfully
created\n");
else
printf("Problem creating directory
'tmp\\sub'\n");
}
This program uses mkdir to create the directories b:\tmp and
tmp\sub.
(printed 6/18/89)