Why does memset take an int instead of a char?

后端 未结 3 1990
梦毁少年i
梦毁少年i 2020-11-28 09:21

Why does memset take an int as the second argument instead of a char, whereas wmemset takes a wchar_t instea

3条回答
  •  孤街浪徒
    2020-11-28 09:47

    Probably the same reason why the functions in take ints and not chars.

    On most platforms, a char is too small to be pushed on the stack by itself, so one usually pushes the type closest to the machine's word size, i.e. int.

    As the link in @Gui13's comment points out, doing that also increases performance.

提交回复
热议问题