Q : Write a program to concatenate two strings. (Do not use inbuilt string function).
Answer :
#include<stdio.h>
#include<conio.h>
/*============================
Girfa Student Help
Concatenation string
==============================*/
void main()
{
char ar1[20],ar2[20],ar3[40];
int i,j;
printf("Enter
first string>> ");
gets(ar1);
printf("Enter
Second string>> ");
gets(ar2);
for(i=0;ar1[i]!='\0';i++)
ar3[i]=ar1[i];
for(j=0;ar2[j]!='\0';j++,i++)
ar3[i]=ar2[j];
ar3[i]='\0';
printf("\nFirst
string is %s",ar1);
printf("\nSeocnd
string is %s",ar2);
printf("\nConcatenation
string is %s",ar3);
getch();
}
No comments:
Post a Comment