C program to remove an empty directory using rmdir() function
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Input the name of the directory (path) and then remove the given empty directory using the rmdir() function.
The rmdir() function is a library function of <sys/types.h> header file which is used to remove an empty directory, the directory must not contain any files or directories.
Syntax:
The argument path is the path of the directory that you want to delete.
The function returns 0 if the directory is removed successfully, it returns -1 if the directory is the current working directory of any process, If the directory is the root directory, the effect of this function depends on the filesystem.
Program:
The source code to remove an empty directory using the rmdir() function is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.
Output:
Explanation:
Here, we created a character array dirName. Then we read the name of the directory from the user. Then we removed the given directory using the rmdir() function and printed the appropriate message on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer