Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why memccpy function use int parameter?

When I search man of memccpy, I get the format of the function like this

void *memccpy(void *dest, const void *src, int c, size_t n)

I understand that integer c is used as unsigned char by type casting.

Then I think

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

void *memccpy(void *dest, const void *src, unsigned char c, size_t n)

looks better. Is there any reason memccpy must use int intparameter?

>Solution :

In ancient C, there was no way to pass an argument as an unsigned char; all arguments were promoted to at least int. Changing the parameter type to unsigned char now would break compatibility. (That could possibly be worked around, but there is no demand for it.)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading