_mkdir

Description

Creates a new directory.

#include <direct.h> Required only for function declarations  

int _mkdir( char *dirname );

dirname Path name for new directory  

Remarks

The _mkdir function creates a new directory with the specified dirname. Only one directory can be created at a time, so only the last component of dirname can name a new directory.

The _mkdir function does not do any translation of path-name delimiters. All operating systems accept either “ \” or “/ ” internally 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.

Compatibility

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

See Also

_chdir, _rmdir

Example

/* MAKEDIR.C */

#include <direct.h>

#include <stdlib.h>

#include <stdio.h>

void main( void )

{

int result;

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" );

else

printf( "Problem removing directory '\\testtmp'\n" );

}

else

printf( "Problem creating directory '\\testtmp'\n" );

}

Output

Directory '\testtmp' was successfully created

The volume label in drive C is ZEPPELIN

Directory of C:\TESTTMP

. <DIR> 12-19-99 11:20a

.. <DIR> 12-19-99 11:20a

2 File(s) 12730368 bytes free

Directory '\testtmp' was successfully removed