读书人

缓冲输出的小疑点

发布时间: 2013-03-14 10:33:15 作者: rapoo

缓冲输出的小问题


#include <stdio.h>

int main(void)
{
int c = 0;

static char buf[1];
setbuf(stdout, buf);

while(c != EOF) {
printf("start\n");
c = getchar();
putchar(c);
printf("end\n");
}
return 0;
}

// 为什么不管输入什么 都不输出?
c
[解决办法]

void setbuf ( FILE * stream, char * buffer );

buffer
User allocated buffer. Shall be at least BUFSIZ bytes long. Alternatively, a null pointer can be specified to disable buffering

读书人网 >C语言

热点推荐