| #include <stdio.h> #include <unistd.h>
 #include <unistd.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdlib.h>
 
 int main()
 {
 char c;
 int in,out;
 int rc;
 in = open("file1",O_RDONLY);
 out = open("file2",O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
 while( ( rc = read(in,&c,1)) == 1)
 {
 printf("%d.\n",rc);
 write(out,&c,1);
 }
 exit(0);
 }
 
 想把file1复制到file2。源文件46k,实际只复制了4k。
 mingw编译的。
 
 网上查的资料说,文件很快读完了,所以读到字节不正确了。
 
 
 
 |