UMASK.C
上传用户:qq5388545
上传日期:2022-07-04
资源大小:29849k
文件大小:1k
- #include <stdio.h>
- #include <io.h>
- #include <fcntl.h>
- #include <sysstat.h>
- #include <stdlib.h>
- void main(void)
- {
- int output;
- int old_setting;
- old_setting = umask(S_IWRITE);
- if ((output = creat("OUTPUT.DAT", S_IWRITE)) == -1)
- {
- fprintf(stderr, "Error creating OUTPUT.DATn");
- exit(1);
- }
- else
- {
- if (write(output, "Test", 4) == -1)
- fprintf(stderr, "Cannot write to file opened for write accessn");
- else
- printf("File successfully written ton");
-
- close(output);
- }
- if ((output = open("OUTPUT.DAT", O_WRONLY)) == -1)
- fprintf(stderr, "Error opening OUTPUT.DAT for outputn");
- else
- printf("File successfully opened for write accessn");
- }