Home  >  Article  >  Backend Development  >  What is the function of strcat function?

What is the function of strcat function?

coldplay.xixi
coldplay.xixiOriginal
2020-07-24 15:23:209027browse

The function of strcat function is to connect two char types, the code is [char d[20]="Golden";char s[20]="View";strcat(d,s);] where The memory areas pointed to by d and s cannot overlap and d must have enough space to accommodate the string of s.

What is the function of strcat function?

The function of strcat function is to connect two char types.

For example:

char d[20]="Golden";
char s[20]="View";
strcat(d,s);
//打印d
printf("%s",d);

The output

 d

is GoldenView (no space in the middle)

The memory areas pointed by d and s cannot overlap and d must have enough space to hold s's string.

Return the pointer to d.

What is the function of strcat function?

Extended information

In C, the function prototype exists in the header file.

In C, it exists in the header file.

Copy the string pointed to by src (including "\0") to the end of the string pointed to by dest (delete the "\0" at the original end of *dest). Make sure *dest is long enough to accommodate the copied *src. The original characters in *src remain unchanged. Returns a pointer to dest.

Note: The memory areas pointed to by src and dest cannot overlap and dest must have enough space to accommodate the string of src.

Related learning recommendations: C video tutorial

The above is the detailed content of What is the function of strcat function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn