The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017

_mkdir, _wmkdir


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at _mkdir, _wmkdir.

Creates a new directory.

      int _mkdir(  
   const char *dirname   
int _wmkdir(  
   const wchar_t *dirname   


Path for a new directory.

Each of these functions returns the value 0 if the new directory was created. On an error, the function returns –1 and sets errno as follows.

Directory was not created because dirname is the name of an existing file, directory, or device.

Path was not found.

For more information about these and other return codes, see _doserrno, errno, _sys_errlist, and _sys_nerr.

The _mkdir function creates a new directory with the specified dirname. _mkdir can create only one new directory per call, so only the last component of dirname can name a new directory. _mkdir does not translate path delimiters. In Windows NT, both the backslash ( \) and the forward slash (/ ) are valid path delimiters in character strings in run-time routines.

_wmkdir is a wide-character version of _mkdir; the dirname argument to _wmkdir is a wide-character string. _wmkdir and _mkdir behave identically otherwise.

Generic-Text Routine Mappings

Tchar.h routine_UNICODE and _MBCS not defined_MBCS defined_UNICODE defined
RoutineRequired header
_wmkdir<direct.h> or <wchar.h>

For more compatibility information, see Compatibility in the Introduction.

All versions of the C run-time libraries.

// crt_makedir.c  
#include <direct.h>  
#include <stdlib.h>  
#include <stdio.h>  
int main( void )  
   if( _mkdir( "\\testtmp" ) == 0 )  
      printf( "Directory '\\testtmp' was successfully created\n" );  
      system( "dir \\testtmp" );  
      if( _rmdir( "\\testtmp" ) == 0 )  
        printf( "Directory '\\testtmp' was successfully removed\n"  );  
         printf( "Problem removing directory '\\testtmp'\n" );  
      printf( "Problem creating directory '\\testtmp'\n" );  

Directory '\testtmp' was successfully created  
 Volume in drive C has no label.  
 Volume Serial Number is E078-087A  
 Directory of C:\testtmp  
02/12/2002  09:56a      <DIR>          .  
02/12/2002  09:56a      <DIR>          ..  
               0 File(s)              0 bytes  
               2 Dir(s)  15,498,690,560 bytes free  
Directory '\testtmp' was successfully removed  

Directory Control
_chdir, _wchdir
_rmdir, _wrmdir