what is the difference between scansets in scanf() function?

后端 未结 2 1347
遥遥无期
遥遥无期 2021-01-20 00:17

I have read all of the questions about these, but I have not found an explanation for the difference between %[^\\n]s and %[^\\n] in the scan

2条回答
  •  情话喂你
    2021-01-20 00:46

    Adding [^\n] in scanf() means skip over any new line char. It consumes all apart from new line char.

    The the * flag signals that no assignment should be made. In this case * char. [\n] skips over any leading newline characters

    In other words: %*[^\n] scans means everything until a \n(Doesn't scan \n) and discards.

提交回复
热议问题