Files
system-programming/chp2/fopenflags.c
Fabio Scotto di Santolo dd53e83af6 Reformat code
2025-07-04 10:39:07 +02:00

31 lines
486 B
C

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
int main(void)
{
int fd;
fd = open("test.txt", O_CREAT | O_EXCL);
if (fd == -1)
perror("First open");
close(fd);
fd = open("test.txt", O_CREAT | O_EXCL);
if (fd == -1)
perror("Second open");
close(fd);
fd = open("test.txt", O_CREAT | O_EXCL);
if (fd == -1)
perror("Third open");
close(fd);
fd = open("test.txt", O_CREAT);
if (fd == -1)
perror("Fourth open");
close(fd);
return 0;
}