C & C++ 관련
File Copy LowLevel
Real_G
2007. 3. 28. 21:18
반응형
01: #include<stdio.h> 02: #include<fcntl.h> 03: #include<sys/stat.h> 04: void main(int argc, char *argv[]) 05: { 06: int src, dest; 07: int readnum; 08: void *buf; 09: 10: src=open(argv[1],O_RDONLY); 11: dest=open(argv[2],O_CREAT | O_WRONLY | O_TRUNC, S_IXUSR|S_IRUSR|S_IWUSR) ; 12: buf=malloc(sizeof(src)); 13: for (;;) { 14: readnum=read(src,buf,sizeof(src)); 15: if (readnum == 0) { 16: break; 17: } 18: write(dest,buf,readnum); 19: } 20: close(src); 21: close(dest); 22: free(buf); 23: }
반응형