Deletes a directory.
#include <direct.h> | Required only for function declarations |
int _rmdir( char *dirname );
dirname | Path name of directory to be removed |
The _rmdir function deletes the directory specified by dirname. The directory must be empty, and it must not be the current working directory or the root directory.
The _rmdir function returns the value 0 if the directory is successfully deleted. A return value of –1 indicates an error, and errno is set to one of the following values:
Value | Meaning |
EACCES | The given path name is not a directory; or the directory is not empty; or the directory is the current working directory or the root directory. |
ENOENT | Path name not found. |
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
/* 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” );
}
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