Search code examples
c++cmemset

What's the use of memset() return value?


memset() is declared to return void* that is always the same value as the address passed into the function.

What's the use of the return value? Why does it not return void?


Solution

  • The signature is in line with all the other similar functions: memcpy(), strcpy() etc. I always thought this was done to enable one to chain calls to such functions, and to otherwise use such calls in expressions.

    That said, I've never come across a real-world situation where I would feel compelled to use the return value in such a manner.