C program to Concat String using pointer

C program to Concat String using Pointer  . compiled in DEV C++

 

 

#include<stdio.h>
#include<string.h>
#include<conio.h>
void concat_string(char a[],char *b);
main()
{
char a[30],b[30];
printf("\n Program to Concat String Using Pointer\n");
printf("\n--------------------------------------------------------\n\n\n");
printf("First Text : ");
gets(a);
printf("\nSecond Text : ");
gets(b);
concat_string(a,b);
printf("\nNew text : %s",a);

getch();
}

void concat_string(char a[],char *b)
{
int length=0;
length=strlen(a);

while(*b!='\0')
{
a[length]=*b;

b++;
length++;

}

a[length]='\0';

}

 

Output

concat

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s