Program to Concatenate Strings using Pointer

0 June 15, 2021

In this example, We will learn a simple program to Concatenate Strings using Pointer. Before that, You must have knowledge of the following topics.

Download Application: Learn C Programming with Live Compiler


This is the algorithm of this program

Step 1: Start
Step 2: Initialize string variables aa and bb
Step 3: Takes string input from user and store in aa and bb
Step 4: Declare Pointer variables a and b
Step 5: a = aa and b = bb
step 6: REPEAT this step until pointer a is NULL
        Increase a by 1
step 7: REPEAT this step until pointer b is NULL
        *a = *b
        Increase b by 1
        Increase a by 1
Step 8: *a = \'\\0\'
Step 9: Print aa
Step 10: End


This is the flowchart of this program

Flowchart : Program to Concatenate Strings using Pointer

CODE: Concatenate Strings using Pointer

Now, We will see the main code to concatenate two strings using pointers.

#include <stdio.h>

int main()
    char aa[100], bb[100];

    printf("\nEnter string: ");

    printf("\nEnter the string to be concatenated: ");

    char *a = aa;
    char *b = bb;

    // pointing to the end of the 1st string

        *a = *b;
    *a = '\0';
    printf("\nThe string after concatenation is: %s ", aa);
    return 0;

The output of above program is

Enter string: Hello 

Enter the string to be concatenated: World

The string after concatenation is: Hello World
Notify of
Inline Feedbacks
View all comments

Join Our Newsletter Now

Get the latest tutorials, examples and projects updates.

Ads Block Detector Powered by

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Disable Ad Block

Want Same System