/* * File name: copy.c * Date: 2006/10/26 14:39 * Author: */ #include #include #include #include int main(int argc, char **argv) { int fin, fout; char buff[4096]; size_t readen; if (argc != 3) { printf( "%s fin fout\n", argv[0]); exit( 255 ); } if ((fin = open( argv[1], O_RDONLY )) < 0) { perror("open fin"); exit(255); } if ((fout = open( argv[2], O_CREAT|O_WRONLY )) < 0) { perror("open fout"); exit(255); } while (readen = read( fin, buff, sizeof(buff) )) { if (write( fout, buff, readen ) != readen) { printf( "Ouch in write\n" ); close( fin ); close( fout ); exit( 255 ); } } close( fin ); close( fout ); exit( 0 ); } /* end of copy.c */ ~