Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

C Program to Concat Two Strings without Using Library Function

#include<stdio.h>
#include<string.h>
void concat(char[], char[]);
int main() {
	char s1[50], s2[30];
	printf("
Enter String 1 :");
	gets(s1);
	printf("
Enter String 2 :");
	gets(s2);
	concat(s1, s2); //call the function
	printf("
Concated string is :%s", s1);
	return (0);
}
//function to concatiate two string s1 and s2
void concat(char s1[], char s2[]) {
	int i, j;
	i = strlen(s1);
	for (j = 0; s2[j] != ''; i++, j++) {
		s1[i] = s2[j];
	}
	s1[i] = '';
}
 
PREVIOUS NEXT
Tagged: #C #Program #Concat #Two #Strings #Using #Library #Function
ADD COMMENT
Topic
Name
2+6 =