SHARE
TWEET

good strlcat

eg0rmaffin Sep 18th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. size_t      ft_strlcat(char *dst, const char *src, size_t size)
  2. {
  3.     size_t      strlendst;
  4.     size_t      strlensrc;
  5.     size_t      run;
  6.  
  7.     strlendst = ft_strlen(dst);
  8.     strlensrc = ft_strlen(src);
  9.     if (size == 0)
  10.         return (strlensrc);
  11.     if (size - 1 < strlendst)
  12.         return (strlensrc + size);
  13.     run = 0;
  14.     while ((strlendst + run < size - 1) && src[run])
  15.     {
  16.         dst[strlendst + run] = src[run];
  17.         run++;
  18.     }
  19.     dst[strlendst + run] = '\0';
  20.     return (strlendst + strlensrc);
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top