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

sharptooth picture sharptooth · Dec 5, 2012 · Viewed 9.8k times · Source

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

Juraj Blaho picture Juraj Blaho · Dec 5, 2012

It may be used for call chaining like:

char a[200];
strcpy(memset(a, 0, 200), "bla");