C Library Function - strcat()
Description
C Library Function **char *strcat(char dest, const char src) Puts the src appends the string pointed to by dest to the end of the string pointed to by .
Declaration
Below is the declaration of the strcat() function.
char *strcat(char *dest, const char *src)
Parameters
- dest -- points to the destination array, which contains a C string and is large enough to hold the appended string.
- src -- points to the string to be appended, which will not overwrite the destination string.
Return Value
This function returns a pointer to the final destination string dest.
Example
The following example demonstrates the use of the strcat() function.
Example
#include
<
stdio.h
#include
<
string.h
int
main
(
)
{
char
src
[
50
]
,
dest
[
50
];
strcpy
(
src
,
"
This is source
"
)
;
strcpy
(
dest
,
"
This is destination
"
)
;
strcat
(
dest
,
src
)
;
printf
(
"
Final destination string: |%s|
"
,
dest
)
;
return
(
0
)
;
}
Let's compile and run the above program, which will produce the following result:
最终的目标字符串: |This is destinationThis is source|
C Standard Library -