write() to stdout and printf output not interleaved?

后端 未结 5 1927
轻奢々
轻奢々 2020-11-29 07:48
#include 
#define MAXLEN 256

int main() {
  int n;
  char buf[MAXLEN];
  while((n = read(0,buf,sizeof(buf))) != 0){
    printf(\"n: %d:\",n);
    wri         


        
5条回答
  •  有刺的猬
    2020-11-29 08:19

    Use fwrite (streams version) rather than write.

    Note that, while is associated with file number 1, it isn't the same thing.

提交回复
热议问题