What does strcat mean in C language?

Guanhui
Release: 2020-06-15 13:20:20
Original
12442 people have browsed it

What does strcat mean in C language?

#What does strcat mean in C language?

strcat represents a function for appending strings in C language. Its function is to append string A to the end of string B. The value of string A remains unchanged and the string B becomes longer. When appending, you need to ensure that the B string cannot overflow after adding A.

strcat declaration

The following is the declaration of strcat() function.

char *strcat(char *dest, const char *src)
Copy after login

strcat Parameter

dest -- Points to the target array, which contains a C string and is large enough to accommodate the appended string.

src -- Points to the string to be appended, which will not overwrite the target string.

strcat return value

This function returns a pointer to the final target string dest.

strcat 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("最终的目标字符串: |%s|", dest);
   
   return(0);
}
Copy after login

Compiled and run results

最终的目标字符串: |This is destinationThis is source|
Copy after login

Recommended tutorial: "C#"

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

Related labels:
c
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!