What are scanf(“%*s”) and scanf(“%*d”) format identifiers?

前端 未结 5 545
太阳男子
太阳男子 2020-11-30 21:26

What is the practical use of the formats \"%*\" in scanf(). If this format exists, there has to be some purpose behind it. The following program gives weird out

5条回答
  •  半阙折子戏
    2020-11-30 21:51

    The * is used to skip an input without putting it in any variable. So scanf("%*d %d", &i); would read two integers and put the second one in i.

    The value that was output in your code is just the value that was in the uninitialized i variable - the scanf call didn't change it.

提交回复
热议问题