Why is scanf(“%hhu”, char*) overwriting other variables when they are local?

后端 未结 1 461
逝去的感伤
逝去的感伤 2020-12-03 19:30

The title says it all. I\'m using GCC 4.7.1 (bundled with CodeBlocks) and I faced a strange issue. Consider this:

int main() {
    unsigned char a = 0, b = 0         


        
相关标签:
1条回答
  • 2020-12-03 20:03

    The important detail is that you're using Windows, and presumably an outdated or non-conforming C environment (compiler and standard library). MSVCRT only supports C89 (and even then, not entirely correctly); in particular, there was no "hh" modifier in C89, and it's probably interpreting "hh" the same as "h" (i.e. short).

    0 讨论(0)
提交回复
热议问题