Write a program to concatenate two given strings without using string functions

Source Code

#include<stdio.h>
#include<conio.h>
int main (int argc, char *argv[])
{
  clrscr();
  char str[200];
  char str1[100];
  char str2[100];
  int l=0,n=0,i;
  printf("\nEnter first string:");
  gets(str1);
  printf("\nEnter second string:");
  gets(str2);
  while(str1[l]!='\0')
  {
    l++;
  }
  for(i=0;i<=l;i++)
  {
    str[i]=str1[i];
  }
  n=l;
  while(str2[n-l]!='\0')
  {
    str[n]=str2[n-l];
    n++;
  }
  str[n+1]='\0';
  printf("\nThe first string is:");
  puts(str1);
  printf("\nThe second string is:");
  puts(str2);
  printf("\nThe concatenated string is:");
  puts(str);
  getch();
}

Find More from our code collection
Armstrong number, binary number to a decimal number, bubble sort, decimal number to binary number, factorial of the given number factors, fibonacci numbers, HCF and LCM, matrix, mergesort, salary of the employee. palindrome, quadratic equation, star patterns, series etc. and much more...
#Return to Example Source Code