stpcpy.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Implement the stpcpy function.
  2. Copyright (C) 2003 Free Software Foundation, Inc.
  3. Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
  4. This file is part of the libiberty library.
  5. Libiberty is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. Libiberty is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with libiberty; see the file COPYING.LIB. If
  15. not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
  16. Boston, MA 02110-1301, USA. */
  17. /*
  18. @deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src})
  19. Copies the string @var{src} into @var{dst}. Returns a pointer to
  20. @var{dst} + strlen(@var{src}).
  21. @end deftypefn
  22. */
  23. #include <ansidecl.h>
  24. #include <stddef.h>
  25. extern size_t strlen (const char *);
  26. extern PTR memcpy (PTR, const PTR, size_t);
  27. char *
  28. stpcpy (char *dst, const char *src)
  29. {
  30. const size_t len = strlen (src);
  31. return (char *) memcpy (dst, src, len + 1) + len;
  32. }