2/24/2009

C Program To Concatenate Two Strings Without Using Inbuilt Functions


/* C Program To Concatenate Two Strings Without Using Inbuilt Functions*/
#include<stdio.h>
#include<conio.h>
void main()
{
    char str1[10],str2[10],str3[20];
    int i,j;
    clrscr();
       printf("Enter the first string\n");
            scanf("%s",&str1);
       printf("Enter the second string\n");
            scanf("%s",&str2);
           for(i=0;str1[i]!=NULL;i++)
           {
               str3[i]=str1[i];
           }
           str3[i]=' ';
           for(j=0;str2[i]!=NULL;j++)
           {
               str3[i+j+1]=str2[j];
           }
           str3[i+j+1]='\0';
           printf("Resultant strings are %s\n",str3);
           getch();
}
Out Put:
C Program To Concatenate Two Strings Without Using Inbuilt Functions

No comments:

Post a Comment