我能给你打典故吗:UNIX中的READ函数

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 09:41:49
--源代码--------------------------------------
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int fd_in, fd_out, nbytes;
char buf[512];
fd_in = open(argv[1], 0);
fd_out = creat(argv[2], 0644);
nbytes = read(fd_in, buf, 512);
while (nbytes > 0) {
write(fd_out, buf, nbytes);
nbytes = read(fd_in, buf, 512);
} /* while */
}
--代码结束------------------------------------
要将代码中的
nbytes = read(fd_in, buf, 512);
用if ((a = b + c) == d) { ... }
这样的结构替换,应该怎么修改啊

回答的不错啊 !呵呵