isdigit raises a debug assertion when entering £ and ¬

后端 未结 2 1930
予麋鹿
予麋鹿 2020-12-21 21:30

The below code works for every character I type in except for £ or ¬.

Why do I get a \"debug assertion fail\"?

#include <         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-21 21:48

    The Microsoft docs say:

    The behavior of isdigit and _isdigit_l is undefined if c is not EOF or in the range 0 through 0xFF, inclusive. When a debug CRT library is used and c is not one of these values, the functions raise an assertion.

    (I'm guessing Microsoft because of the comment about an "error window", but docs for other implementations place the same limit on argument values.)

    EDIT: as Deduplicator observed, the error probably arises from default char being signed on this platform, so that you are passing negative values (different from EOF). std::string uses char, not wide characters, so my original conclusion cannot be correct.

提交回复
热议问题