C Programming
Computer Programming

C file handling program to change the permissions of file using system() function by specifying the "chmod" command



Write C file handling program to change the permissions of file using system() function by specifying the "chmod" command

\* C file handling program to change the permissions of file using system() function by specifying the "chmod" command *\

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

char filename[15] ;
char cmd[32] ;
int ret = 0 ;

printf("\n Enter the filename to change Permission : ") ;
scanf("%s", filename ) ;
sprintf(cmd, "chmod 666 %s", filename ) ;
ret = system(cmd) ;
if (ret == 0)
      printf("Permissions of file changed successfully\n") ;
else
      printf("Unable to change the permissions of file\n") ;
return 0 ;

}

Output of Program :

Output of C file handling program to change the permissions of file using system() function by specifying the chmod command