1 // kompilacia: gcc -o priklad5 priklad5.c 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 #include <fcntl.h> 6 #include <errno.h> 7 8 int main () { 9 int fd; // pamat pre file descriptor 10 FILE * fp; // pamat pre stream 11 12 fd = open("subor1", O_WRONLY | O_CREAT, 0644); 13 if (fd < 0) { 14 perror("subor1"); 15 exit(EXIT_FAILURE); 16 } 17 write(fd, "nieco 1", 7); 18 close(fd); 19 20 fp = fopen("subor2", "w"); 21 if (!fp) { 22 perror("subor2"); 23 exit(EXIT_FAILURE); 24 } 25 fprintf(fp, "nieco 2"); 26 fclose(fp); 27 28 exit(EXIT_SUCCESS); 29 } 30