I am trying to create a file, but it is opening in locked mode. How to make it in read write execute mode?
switch(choice){
case 1: printf("\n Enter the file: ");
scanf("%s", file);
open(file, O_CREAT, S_IRWXG);
break;
I am trying to create a file, but it is opening in locked mode. How to make it in read write execute mode?
switch(choice){
case 1: printf("\n Enter the file: ");
scanf("%s", file);
open(file, O_CREAT, S_IRWXG);
break;
The third argument of open doesn't actually have to be one of the defined flags. If you want it in +rwe mode for all users, just change your code to
open(file, O_CREAT, 0777);
EDIT: If you'd prefer to use the flags. Just combine them with the | command. You'll end up actually passing the same value in, but many people prefer to use the flags.