String Concat



Arrays and Strings in Tamil

String Concat

  • The strcat (first string, second string) function concatenates two stringsĀ  and result is returned to first string.
 Strcat()

Strcat()

Example

#include<stdio.h> 
#include <string.h> 
void main()
{
	char ch[10]={'w','i','k','i','t','e','c','h','y','\0ā€™};
	char ch2[10]={'.','c','o','m','\0'}; 
	strcat(ch,ch2);
	printf("Value of first string is: %s",ch);
	getch();
} 
 String Concatenate Without Using Strcat()

Learn C - C tutorial - String Concatenate in C - C examples - C programs

Output

Value of first string is : wikitechy.com

String Concatenate Without Using Strcat()

#include <stdio.h>
#include <string.h>
void main()
{ 
       char string1[30], string2[20];
       int i, length=0, temp;
       printf("Enter the Value of String1: ");
       scanf("%s",string1);
       printf(" Enter the Value of String2: ");
       scanf("%s",string2);
       for(i=0; string1[i]!='\0'; i++)
       length++;
       temp = length;
       for(i=0; string2[i]!='\0'; i++)
       {
              string1[temp] = string2[i];
              temp++;
}
       string1[temp] = '\0';
       printf(" The concatenated string is: %sā€œ,string1);
       getch();
}
 String Concatenate Without Using Strcat()

Learn C - C tutorial - String Concatenate Without Using Strcat() - C examples - C programs

Output

Enter the Value of String1 : wikitechy
Enter the Value of String2 : .com
The concatenated string is :wikitechy.com


Related Searches to String Concat