home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / STRECPY.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  1KB  |  41 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  STRECPY.C - A form of strcpy() where the result returned is the
  5. **              NUL terminating character of the first argument. In many
  6. **              cases this function is more efficient than the equivalent
  7. **              strcpy, followed by strcat.
  8. **
  9. **  public domain by Leslie Satenstein and Thad Smith.
  10. **
  11. **  NOTE: The name of this funtion violates ANSI/ISO 9899:1990 sec. 7.1.3,
  12. **        but this violation seems preferable to either violating sec. 7.13.8
  13. **        or coming up with some hideous mixed-case or underscore infested
  14. **        naming. Also, many SNIPPETS str---() functions duplicate existing
  15. **        functions which are supported by various vendors, so the naming
  16. **        violation may be required for portability.
  17. */
  18.  
  19. #include <stdio.h>
  20. #include "sniptype.h"
  21. #include "snip_str.h"
  22.  
  23. #if defined(__cplusplus) && __cplusplus
  24.  extern "C" {
  25. #endif
  26.  
  27. char *strecpy(char *target, const char *src)
  28. {
  29.       if (src && target)
  30.       {
  31.             while ((*target++ = *src++) != NUL)
  32.                   ;
  33.             return (--target);
  34.       }
  35.       else  return NULL;
  36. }
  37.  
  38. #if defined(__cplusplus) && __cplusplus
  39.  }
  40. #endif
  41.