Where does `getchar()` store the user input?

后端 未结 7 2135
情深已故
情深已故 2020-12-16 04:25

I\'ve started reading \"The C Programming Language\" (K&R) and I have a doubt about the getchar() function.

For example this code:

#         


        
7条回答
  •  情书的邮戳
    2020-12-16 05:12

    You're only using the variable c to contain each character one at a time.

    Once you've displayed the first char (t) using putchar(c), you forget about the value of c by assigning the next character (o) to the variable c, replacing the previous value (t).

提交回复
热议问题