Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <unistd.h>
- #define BUFS 1024
- int i=1;
- int main(int argc, char **argv)
- {
- while (--argc > 0) // dopoki sa argumenty
- {
- char *nazwa = argv[i];
- printf(" *nazwa: %s\n", nazwa);
- int fd, n;
- char buf[BUFS + 1];
- // open, read, write, close - niskopoziomowe
- if ((fd = open(nazwa, O_RDWR | O_CREAT, 0600)) == -1)
- perror("Blad");
- // *printf - wysokopoziomowe
- fprintf(stderr, "Wpisz tekst, tekst zostanie zapisany do pliku data\n");
- while ((n = read(fileno(stdin), buf, BUFS)) > 0) {
- buf[n] = '\0';
- write(fd, buf, n);
- }
- close(fd);
- i++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement