几个小时前我问过一个关于这段代码的理论方面的问题。现在我明白了一切,但是,该代码根本没有输出。 这是 http://ideone.com/LWMC5 上代码的链接
代码:
#include <stdio.h>
#include <unistd.h> /* changed from "syscalls.h" it was not working */
/* changed the name intentionally */
int main(void)
{
static char buf[BUFSIZ];
static char *bufp = buf;
static int n = 0;
if (n == 0) { /* buffer is empty */
n = read(0, buf, sizeof buf);
bufp = buf;
}
return (--n >= 0) ? (unsigned char) *bufp++ : EOF;
}
我应该做什么/添加什么来产生输出?
最佳答案
我不明白你期望的输出是什么,要在屏幕上打印一些东西,你需要使用类似 printf
的东西。
关于c - read() 的输出没有合并到 getchar 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12021014/