home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / strcat.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  2KB  |  84 lines

  1. /***
  2. *strcat.c - contains strcat() and strcpy()
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       Strcpy() copies one string onto another.
  8. *
  9. *       Strcat() concatenates (appends) a copy of the source string to the
  10. *       end of the destination string, returning the destination string.
  11. *
  12. *******************************************************************************/
  13.  
  14. #include <cruntime.h>
  15. #include <string.h>
  16.  
  17. #ifndef _MBSCAT
  18. #ifdef _MSC_VER
  19. #pragma function(strcat,strcpy)
  20. #endif  /* _MSC_VER */
  21. #endif  /* _MBSCAT */
  22.  
  23. /***
  24. *char *strcat(dst, src) - concatenate (append) one string to another
  25. *
  26. *Purpose:
  27. *       Concatenates src onto the end of dest.  Assumes enough
  28. *       space in dest.
  29. *
  30. *Entry:
  31. *       char *dst - string to which "src" is to be appended
  32. *       const char *src - string to be appended to the end of "dst"
  33. *
  34. *Exit:
  35. *       The address of "dst"
  36. *
  37. *Exceptions:
  38. *
  39. *******************************************************************************/
  40.  
  41. char * __cdecl strcat (
  42.         char * dst,
  43.         const char * src
  44.         )
  45. {
  46.         char * cp = dst;
  47.  
  48.         while( *cp )
  49.                 cp++;                   /* find end of dst */
  50.  
  51.         while( *cp++ = *src++ ) ;       /* Copy src to end of dst */
  52.  
  53.         return( dst );                  /* return dst */
  54.  
  55. }
  56.  
  57.  
  58. /***
  59. *char *strcpy(dst, src) - copy one string over another
  60. *
  61. *Purpose:
  62. *       Copies the string src into the spot specified by
  63. *       dest; assumes enough room.
  64. *
  65. *Entry:
  66. *       char * dst - string over which "src" is to be copied
  67. *       const char * src - string to be copied over "dst"
  68. *
  69. *Exit:
  70. *       The address of "dst"
  71. *
  72. *Exceptions:
  73. *******************************************************************************/
  74.  
  75. char * __cdecl strcpy(char * dst, const char * src)
  76. {
  77.         char * cp = dst;
  78.  
  79.         while( *cp++ = *src++ )
  80.                 ;               /* Copy src over dst */
  81.  
  82.         return( dst );
  83. }
  84.