Home » NO IDEA » concatenation of two string without using library function

concatenation of two string without using library function

Blog Stats

  • 15,880 hits
December 2013
M T W T F S S
« Oct   Jan »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
/*Given two strings s1: GOOD and s2: MORNING. Develop a ‘C’ program to 
concatenate the strings and display the result as GOOD MORNING*/
#include<stdio.h>
#include<string.h>
int main()
{
	int i;
	char name1[]="good";
	char name2[]="morning";
	char name[50];
	int count=0;
	for(i=0;i<strlen(name1);i++)
	{
		name[count++]=name1[i];
	}
	for(i=0;i<strlen(name2);i++)
	{
		name[count++]=name2[i];
	}
	name[count++]='';// this point indicates the end of string

	printf("\n the resultant string is %s",name);
 return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: