Friday 8 March 2019

c++ - 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?


Answer



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.



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...