不需要标准库的 scanf 等函数,而是直接调用 unix 系统低级IO函数 read。
实现:将任意输入复制到任意输出。
代码如下:
int main() {
char buf[5];
int n;
while ((n = read(0, buf, 5)) > 0) {
write(1, buf, n);
}
return 0;
}
不需要标准库的 scanf 等函数,而是直接调用 unix 系统低级IO函数 read。
实现:将任意输入复制到任意输出。
代码如下:
int main() {
char buf[5];
int n;
while ((n = read(0, buf, 5)) > 0) {
write(1, buf, n);
}
return 0;
}