Unbuffered I/O in ANSI C

前端 未结 3 1537
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 01:37

For the sake of education, and programming practice, I\'d like to write a simple library that can handle raw keyboard input, and output to the terminal in \'real time\'.

3条回答
  •  Happy的楠姐
    2020-12-07 02:22

    To set an open stream to be non-buffered using ANSI C, you can do this:

    #include 
    if (setvbuf(fd, NULL, _IONBF, 0) == 0)
      printf("Set stream to unbuffered mode\n");
    

    (Reference: C89 4.9.5.6)

    However, after that you're on your own. :-)

提交回复
热议问题