How fget works?

后端 未结 4 1931
傲寒
傲寒 2021-01-23 15:31

I am using gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
I am writing a very simple script to take string as input and print the same with the some custom message. Fi

4条回答
  •  孤独总比滥情好
    2021-01-23 16:03

    1. You have a newline character in the input stream when you press "enter" after typing 2 for the first scanf. This is consumed by fgets() initially, hence it prints nothing (You replace the newline by \0).

    2. In the next line, your input is read and echoed after World because you are printing it after it.

提交回复
热议问题