Borland C++ reference

rmdir

raw OCR

Removes a DOS file directory.

Defined in header <dir.h>

Syntax

#include <dir.h>
int rmdir(const char *path);

Portability

DOSUNIXWindowsANSI CC++ only
■■■

Remarks

rmdir deletes the directory whose path is given by path. The directory named by path

m must be empty. m must not be the current working directory. a must not be the root directory.

Return value

rmdir returns 0 if the directory is successfully deleted. A return value of -1 indicates an error, and the global variable errno is set to one of the following:

EACCES Permission denied ENOENT Path or file function not found

See also

Example

#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <dir.h>

#define DIRNAME "testdir.$$$"

int main(void)
{
   int Stat;
   Stat = mkdir (DIRNAME);
   if (!stat)
      printf("Directory createdVn") ;
   else {
      printf("Unable to create  directory\n");
   exit(l);
}
getchO;
system ("dir/p");
getchO ;
Stat = rmdir (DIRNAME);
if (!stat)
   printf ("\nDirectory deleted\n");
else {
   perror ("\nUnable to delete directory\n"
   exit(l);
}
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.