linux下cp命令的简单实现方式: #include <stdio.h> #define BUFFERSIZE 4096 int oops(char *, char *); main(int ac, char *av[]) if ( (in_fd=open(av[1], O_RDONLY)) == -1 ) if ( (out_fd=creat( av[2], COPYMODE)) == -1 ) while ( (n_chars = read(in_fd , buf, BUFFERSIZE)) > 0 ) /* close files */ if ( close(in_fd) == -1 || close(out_fd) == -1 ) int oops(char *s1, char *s2) |
|
来自: ColonelLee > 《解决之道》