首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

缓冲输出的小疑点

2013-03-14 
缓冲输出的小问题#include stdio.hint main(void){int c 0static char buf[1]setbuf(stdout, buf)w

缓冲输出的小问题


#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

热点排行