fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4.  
  5. int main() {
  6. char dirname[100];
  7.  
  8. printf("Enter the directory name to delete: ");
  9. scanf("%s", dirname);
  10.  
  11. // Using rmdir system call to delete the directory
  12. int status = rmdir(dirname);
  13.  
  14. if (status == 0) {
  15. printf("Directory '%s' deleted successfully.\n", dirname);
  16. } else {
  17. printf("Error deleting directory '%s'.\n", dirname);
  18. perror("rmdir");
  19. }
  20.  
  21. return 0;
  22. }
Success #stdin #stdout #stderr 0s 5296KB
stdin
Standard input is empty
stdout
Enter the directory name to delete: Error deleting directory ''.
stderr
rmdir: No such file or directory