Is `sscanf` guaranteed not to change arguments that it doesn't find?

前端 未结 5 862
你的背包
你的背包 2021-01-13 05:52

I have a case where I\'m not sure if I\'ll get enough input for sscanf. Can I safely assume that sscanf won\'t mess with any argument that it doesn

5条回答
  •  逝去的感伤
    2021-01-13 06:28

    From http://pubs.opengroup.org/onlinepubs/009695399/functions/scanf.html:

    ... If the format is exhausted while arguments remain, the excess arguments shall be evaluated but otherwise ignored.

    Edit: As Kerrek correctly noticed, the above statement does not apply here. It is about sscanf("1", "%d", &a, &b, &c), and not about sscanf("1", "%d %d %d", &a, &b, &c) as in the question.

提交回复
热议问题