如何去掉I/O流的行缓冲??
以这个程序为例(不是我写的,借来用用),是输入了一行后等待回车才会输出一行的
如果去掉行缓冲,应该就可以输入一个(不等待回车)就输出一个
我试过setbuf(),和setvbuf()两个标准函数,可未见效果。请指教!
#include "stdio.h"
int main(void)
{
int c;
setvbuf(stream,NULL,_IONBF,0);
while ( (c = getc(stdin)) != EOF)
if (putc(c, stdout) == EOF)
printf("output error");
if (ferror(stdin))
printf("input error");
return 0;
}