C String – strcat() function1 min read

strcat() function is used to combine two string together to form a single string in a program.

It concatenates two strings and the final result is returned to the first string. The strcat() function is defined in the header file string.h.

It takes two arguments, the name of the first string and the second string. These two strings are joined together and the first string stores the final result. And is written as follows:

strcat(first_string, second_string);

C Program for strcat() function

Output:

After concatenation: This is Simple2Code website.


C String – strncat function

It is the same as the above strcat() function but here the difference is that it takes the third argument for n number of characters to be concatenated from the second string to the first string in a program. Like strcat, the result will be stored in the first string.

It is written as follows:

strncat(first_string, second_string, n);

C Program for strncat() function

Output:

After concatenation: This is Simp


MORE

Keith Number Program in C

In this tutorial, we will write a Keith number in C. It is one of the most asked questions in an interview. Before that, you …
Read More

Keith Number Program in C++

In this tutorial, we will write a Keith number in C++. It is one of the most asked questions in an interview. Before that, you …
Read More

Singly linked list Program C++

In this tutorial, we will write a C++ program to implement singly linked list. In this program, we will create a separate function for each …
Read More

Fascinating Number Program in C

In this tutorial, we will write a C program to check whether the given number is a Fascinating number or not. You may go through …
Read More

Peterson Number in C

In this tutorial, we will learn about the Peterson number and check if the number is Peterson or not in C. What is Peterson Number? …
Read More

Peterson Number in C++

In this tutorial, we will learn about the Peterson number and write a C++ program to check if the given number is a Peterson number …
Read More