C Programming
Computer Programming

C file handling program to remove an empty directory by specifying the "rmdir" command



Write C file handling program to remove an empty directory by specifying the "rmdir" command

\* C file handling program to remove an empty directory by specifying the "rmdir" command *\

# include < stdio.h >
# include < stdlib.h >
int   main( )
{

char dirName[16] ;
char cmd[32] = { 0 } ;
int ret = 0 ;

printf("\n Enter directory name: ") ;
scanf("%s", dirName) ;
sprintf(cmd, "rmdir %s", dirName ) ;
ret = system(cmd) ;
if (ret == 0)
      printf(" Given Empty directory deleted successfully\n") ;
else
      printf(" Unable to delete directory %s\n", dirName ) ;
return 0 ;

}

Output of Program :

Output of C file handling program to remove an empty directory by specifying the rmdir command