C language strcat () function: connection string, strcat string

Source: Internet
Author: User

C language strcat () function: connection string, strcat string

Header file: # include <string. h>


The strcat () function is used to connect strings. Its prototype is:
Char * strcat (char * dest, const char * src );

[Parameter] dest is the destination string pointer and src is the source string pointer.

Strcat () copies the src string to the end of the string indicated by the dest parameter. The end character NULL at the end of the dest parameter is overwritten, and a NULL value is added at the end of the connected string.

Note: dest and src cannot overlap the memory space, and dest must have enough space to accommodate the string to be copied.

Return Value: the start address of the dest string.

[Instance] connects the string and outputs it.
----------------------------------------------------------

# Include <stdio. h>
# Include <string. h>


Int main (void)
{
Char str [80];
Strcpy (str, "here ");
Strcat (str, "is ");
Strcat (str, "");
Strcat (str, "xiaoz ");
Puts (str );
Return 0;
}
-----------------------------------------------------------

Output result:
Here is the xiaoz


There are many string processing functions in other languages, and the string processing in C language is very troublesome.
(PS: leave a mark and use it later)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.