Why do ZeroMemory, etc. exist when there are memset, etc. already?

前端 未结 8 1106
萌比男神i
萌比男神i 2020-12-10 00:55

Why does ZeroMemory(), and similar calls exist in the Windows API when there are memset and related calls in the C standard library already? Which ones should I

8条回答
  •  渐次进展
    2020-12-10 01:44

    Because the Windows API should be language-agnostic. It provides sufficient functionality for developers, regardless of the language they use. Of course, eventually many functions will duplicate existing functionality offered by the languages.

    You should call the winapi functions (and macros) directly whenever you need a certain level of control -- compare fopen() with CreateFile() for instance. Otherwise, prefer language-specific constructs over API calls. At least, you gain more platform-independence.

提交回复
热议问题