C Program To Concatenate Two Strings Using Strcat Function
C Program To Concatenate Two Strings Using Strcat Function
contributed by:
www.programmingsimplysolved.com
#include<stdio.h>
#include<conio.h>
// string.h contains built in string functions
#include<string.h>
void main()
{
char str1[30], str2[30];
int i:
printf(“.. c program to concatenate two strings using strcat function…”)
printf(“Enter first string “);
gets(str1);
printf(“Enter next string to concatenate “);
gets(str2);
strcat(str1, str2); //concatenates str1 & str2 and saves in str1
printf(“concatenation of two strings using strcat is %s\n”,str1);
getch();
}
OUTPUT:
----------------------------------------------------
Other programs:
c programs on storage classes
number logics
amicable or not
Prime number or not
Perfect number or not
Palindrome number or not
matrices
files
strings
other c programs
-----------------------------------------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
// string.h contains built in string functions
#include<string.h>
void main()
{
char str[30], str2[30];
int i:
printf(“..To concatenate ten strings usind strcat…”)
printf(“Enter first string “);
gets(str1);
for( i=1;i<10;i++)
//you can set n intead of 10 for multiple strings
{
printf(“Enter next string to concatenate “);
gets(str2); // To concatenate a space add strCat( str1, ” “); next to this
strcat(str1, str2); //concatenates str1 & str2 and saves in str1
}
printf(“concatenation of ten strings using strcat is %s\n”,str1);
getch();
}
OUTPUT:
www.programmingsimplysolved.com
#include<stdio.h>
#include<conio.h>
void main()
{
char *str1, *str2;
printf(” … c program to concatenate two strings without strcat() using arrays…”)
printf(“Enter first string “);
gets(str1);
printf(“Enter second string “);
gets(str2);
while (*str1!=’\0′)
*str1++ ;
while (*str2!=’\0′)
*str1++=*str2++
printf(“concatenation of two strings without strcat using pointers is %s\n”,str1);
getch();
}
OUTPUT:
#include<stdio.h>
#include<conio.h>
void main()
{
char *str1, *str2;
printf(” … To concatenate two strings without strcat() using functions…”)
printf(“Enter first string “);
gets(str1);
printf(“Enter second string “);
gets(str2);
str_concatinate(*str1, *str2)
getch();
}
OUTPUT: