我在论坛上发现了这个代码,它工作正常,但我不知道它是如何工作的,为什么它工作。有人能告诉我关于此代码的几句话吗?我想了解它并知道如何使用它。或者如果你知道更好的方法,如何将数据输入到bin。来自txt文件的文件,你能给我一些建议吗?C程序如何从txt文件加载数据?
#include <stdio.h>
#define BLOCK_SIZE 256
int main(void)
{
char buf[BLOCK_SIZE];
size_t bytes;
while(!feof(stdin)) {
bytes = fread(buf, 1, BLOCK_SIZE, stdin);
fwrite(buf, 1, bytes, stdout);
}
return 0;
}
非常感谢。
你有没有至少阅读http://www.cplusplus.com/reference/cstdio/fread/和http://www.cplusplus.com/reference/cstdio/fwrite/? –
有人写了这个?告诉他们while(!feof(stdin))'是错误的http://stackoverflow.com/questions/5431941/why-is-while-feof-file-always-wrong –
为什么C++标记是C语言题? –