0

code:

while(  (c = getchar()) != EOF ){
    putchar( c );
}

when I input abc

I guess the output is aabbcc , but the output is

abc
abc

why ?

  • 1
    It uses buffered streams. For example, you can delete characters using the Backspace key until you press the enter key. – BLUEPIXY Jun 01 '17 at 05:52
  • 1
    `putchar()`, among other I/O functions, is buffered. The output doesn't appear until the output is flushed. And since your program doesn't call `flush()` or call an input function after `putchar()`, I assume that it occurs only when your program ends. – ktb Jun 01 '17 at 05:56

0 Answers0