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

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×