xref: /reactos/sdk/lib/ucrt/string/strcat.c (revision e3e520d1)
1 /***
2 *strcat.c - contains strcat() and strcpy()
3 *
4 *       Copyright (c) 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 <string.h>
15 
16 #ifndef _MBSCAT
17     #pragma function(strcat, strcpy)
18 #endif
19 
20 /***
21 *char *strcat(dst, src) - concatenate (append) one string to another
22 *
23 *Purpose:
24 *       Concatenates src onto the end of dest.  Assumes enough
25 *       space in dest.
26 *
27 *Entry:
28 *       char *dst - string to which "src" is to be appended
29 *       const char *src - string to be appended to the end of "dst"
30 *
31 *Exit:
32 *       The address of "dst"
33 *
34 *Exceptions:
35 *
36 *******************************************************************************/
37 
38 char * __cdecl strcat (
39         char * dst,
40         const char * src
41         )
42 {
43         char * cp = dst;
44 
45         while( *cp )
46                 cp++;                   /* find end of dst */
47 
48         while((*cp++ = *src++) != '\0') ;       /* Copy src to end of dst */
49 
50         return( dst );                  /* return dst */
51 
52 }
53 
54 
55 /***
56 *char *strcpy(dst, src) - copy one string over another
57 *
58 *Purpose:
59 *       Copies the string src into the spot specified by
60 *       dest; assumes enough room.
61 *
62 *Entry:
63 *       char * dst - string over which "src" is to be copied
64 *       const char * src - string to be copied over "dst"
65 *
66 *Exit:
67 *       The address of "dst"
68 *
69 *Exceptions:
70 *******************************************************************************/
71 
72 char * __cdecl strcpy(char * dst, const char * src)
73 {
74         char * cp = dst;
75 
76         while((*cp++ = *src++) != '\0')
77                 ;               /* Copy src over dst */
78 
79         return( dst );
80 }
81