A simplified copying program

Nasza ocena:

3
Wyświetleń: 448
Komentarze: 0
Notatek.pl

Pobierz ten dokument za darmo

Podgląd dokumentu
A simplified copying program - strona 1

Fragment notatki:

A simplified copying program #include #include #define PERMS 0666 /* RW for owner, group, others */ /* cp: copy f1 to f2 */ int main(int argc, char *argv[]) { int f1, f2, n; char buf[BUFSIZ]; if (argc != 3) fprintf(stderr,"Usage: cp from to"); if ((f1 = open(argv[1], O_RDONLY, 0)) == -1) fprintf(stderr,"cp: can't open %s", argv[1]); if ((f2 = creat(argv[2], PERMS)) == -1) fprintf(stderr,"cp: can't create %s, mode %03o", argv[2], PERMS); while ((n = read(f1, buf, BUFSIZ)) 0) if (write(f2, buf, n) != n) fprintf(stderr,"cp: write error on file %s", argv[2]); return 0; } ... zobacz całą notatkę



Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz