EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+
 

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;
10    printf("\nEnter first string:");
11    gets(str1);
12    printf("\nEnter second string:");
13    gets(str2);
14    while(str1[l]!='\0')
15    {
16      l++;
17    }
18    for(i=0;i<=l;i++)
19    {
20      str[i]=str1[i];
21    }
22    n=l;
23    while(str2[n-l]!='\0')
24    {
25      str[n]=str2[n-l];
26      n++;
27    }
28    str[n+1]='\0';
29    printf("\nThe first string is:");
30    puts(str1);
31    printf("\nThe second string is:");
32    puts(str2);
33    printf("\nThe concatenated string is:");
34    puts(str);
35    getch();
36  }

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