What is the effect of trailing white space in a scanf() format string?

后端 未结 4 1802
小蘑菇
小蘑菇 2020-11-21 07:01

What is difference between scanf(\"%d\") and scanf(\"%d \") in this code, where the difference is the trailing blank in the format string?

4条回答
  •  不要未来只要你来
    2020-11-21 07:31

    A whitespace character in your scanf format matches any number of whitespace characters as described by isspace. So if you have tailing spaces, newlines, tabulators or any other whitespace character then it will also be consumed by scanf before it returns.

提交回复
热议问题