mkdir
raw OCR
Creates a directory.
Defined in header <dir.h>
Syntax
#include <dir.h>
int mkdir(const char *path);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ |
Remarks
mkdir is available on UNIX System V systems, though it then takes an additional parameter.
mkdir creates a new directory from the given path name path.
Return value
mkdir returns the value 0 if the new directory was created.
A return value of -1 indicates an error, and the global variable errno is set to one of the following values:
EACCES Permission denied ENOENT No such file or directory
See also
Example
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <dir.h>
int main(void)
{
int status;
clrscrO;
status = mkdir ("asdfjklm");
([status) ? (printf("Directory created\n")) :
(printf("Unable to create directory\n"));
getchO ;
system("dir") ;
getchO ;
status = rmdir ("asdfjklm");
if (status == 0)
printf ("Directory deleted\n");
else
perror("Unable to delete directory");
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/dir.h/mkdir/
· short form /3.1/mkdir/