Keil Logo


4.37 strlcpy()

Defined in string.h, the strlcpy() function copies up to size-1 characters from the NUL-terminated string src to dst.


extern size_t strlcpy(char *dst, const char *src, size_t size);


strlcpy() takes the full size of the buffer, not only the length, and terminates the result with NUL as long as size is greater than 0. Include a byte for the NUL in your size value.
The strlcpy() function returns the total length of the string that would have been copied if there was unlimited space. This might or might not be equal to the length of the string actually copied, depending on whether there was enough space. This means that you can call strlcpy() once to find out how much space is required, then allocate it if you do not have enough, and finally call strlcpy() a second time to do the required copy.
This function is a common BSD-derived extension to many C libraries.
Non-ConfidentialPDF file icon PDF versionARM DUI0378H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.