Source Code:
#include <stdio.h>
int main()
{
char a[30], b[30], i, j;
printf("Enter first string: ");
scanf("%s", a);
printf("Enter second string: ");
scanf("%s", b);
for(i = 0; a[i] != '\0'; ++i);
for(j = 0; b[j] != '\0'; ++j, ++i)
{
a[i] = b[j];
}
a[i] = '\0';
printf("After concatenation: %s", a);
return 0;
}
Output:
D:\D INSTALL\TDM-GCC-32\Programs>Concatstr.exe
Enter first string: dharani
Enter second string: dharan
After concatenation: dharanidharan
Also see:
#include <stdio.h>
int main()
{
char a[30], b[30], i, j;
printf("Enter first string: ");
scanf("%s", a);
printf("Enter second string: ");
scanf("%s", b);
for(i = 0; a[i] != '\0'; ++i);
for(j = 0; b[j] != '\0'; ++j, ++i)
{
a[i] = b[j];
}
a[i] = '\0';
printf("After concatenation: %s", a);
return 0;
}
Output:
D:\D INSTALL\TDM-GCC-32\Programs>Concatstr.exe
Enter first string: dharani
Enter second string: dharan
After concatenation: dharanidharan
Also see:
- Reversing of Number using C Program
- Palindrome Number or not using C Program
Thanks and Regards,
Tech Bird
Comments