备忘: c写文件
创建个1M的文件 562 ~/script/notsobad/c/0105>dd if=/dev/zero of=file.in bs=1024 count=1024 记录了1024+0 的读入 记录了1024+0 的写出 1048576字节(1.0 MB)已复制,0.0125037 秒,83.9 MB/秒 563 ~/script/notsobad/c/0105>ls -lh 总计 1.1M -rw-r--r-- 1 wang wang 1.0M 2010-01-05 21:42 file.in 拷贝文件: #include #include #include #include #include int main(){ char c[1024]; int in, out; int nread; in = open("file.in", O_RDONLY); out = open("file.out", O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR); while( (nread = read(in, c, 1024)) > 0 ) write(out, c, nread); }