C Program to concatenate two strings without using string functions

How to write a C Program to concatenate two strings without using string functions in C Programming Language ?

This C Program to concatenate two strings without using string functions.

Solution:

  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5.     char a[50],b[50];
  6.     int i,j,n,k;
  7.     clrscr();
  8.     printf("\n Please Give The STRING OF A : ");
  9.     scanf("%s",a);
  10.     printf("\n Please Give The STRING OF B : ");
  11.     scanf("%s",b);
  12.     for(i=0,k=0;a[i]!='\0';i++)
  13.         k++;
  14.     for(j=0,n=0;b[j]!='\0';j++)
  15.         n++;
  16.     printf("VALUE OF K=%d",k);
  17.     printf("VALUE OF N=%d",n);
  18.     for(i=k,j=0;i<=n+k;i++,j++)
  19.             a[i]=b[j];
  20.     printf("\n THE Concatenated string is %s .",a);
  21.     getch();
  22. }


Learn More :