C Program to Concatenate Two Strings Using Pointers

In this tutorial you will learn about the C Program to Concatenate Two Strings Using Pointers and its application with practical example.

C Program to Concatenate Two Strings Using Pointers

In this tutorial, we will learn to create a C program that will Concatenate Two Strings Using Pointers in C programming.

Table Of Contents

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • While loop in c programming.

Concatenate Two Strings Using Pointers

As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First will take the number of elements of string 1 from the user. Then will take the number of elements of string 2 from the user. Then will take the elements from the user for string 1 and as well as for string 2. And concatenate them using the pointer.

With the help of this program, we can Concatenate Two Strings Using Pointers.

Algorithm:-

Program to Concatenate Two Strings Using Pointers:-

 

Output:-

The above program we have first initialize the required variable.

  • string1[20] = it will hold the string value.
  • string2[20] = it will hold the string value.
  • i = it will hold the integer value.
  • j = it will hold the integer value.
  • *str1 = pointer type variable 1.
  • *str2 = pointer type variable 2.

Input strings from the user.

While loop body for concatenating the strings using the pointers and printing the concatenated string.

 

In this tutorial we have learn about the C Program to Concatenate Two Strings Using Pointers and its application with practical example. I hope you will like this tutorial.