Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to concatenate of two strings without using strcat function

Posted By: Hayden Evans     Category: C Programming     Views: 53357

Write a program to append one string s2 to another string s1 i.e. concatenation of two strings without using strcat function

Code for Program to concatenate of two strings without using strcat function in C Programming







   NAME:NAYAN SHAH

   ROLL NO: 48

   SEMISTER: 1

   DEFINATION:  43. Write a program to append one string s2 to another string
        s1 i.e. concatenation of two strings. (Without using strcat
        function)

------------------------------------------------------------------------------


#include<stdio.h>
#include<conio.h>
void main()
{
    char a[50],b[50];
    int i,j,n,k;
    clrscr();
    printf("\n Please Give The STRING OF A : ");
    scanf("%s",a);
    printf("\n Please Give The STRING OF B : ");
    scanf("%s",b);
    for(i=0,k=0;a[i]!='\0';i++)
        k++;
    for(j=0,n=0;b[j]!='\0';j++)
        n++;
    printf("VALUE OF K=%d",k);
    printf("VALUE OF N=%d",n);
    for(i=k,j=0;i<=n+k;i++,j++)
            a[i]=b[j];

    printf("\n THE Concatenated string is %s .",a);
    getch();
}


--------------------------------- OUTPUT ---------------------------------




 Please Give The STRING OF A : SHAH

 Please Give The STRING OF B : NAYAN

VALUE OF K= 4VALUE OF N= 5


 THE Concatenated stringis SHAHNAYAN .




--------------------------------------------------------------------------
  
Share: 



Hayden Evans
Hayden Evans author of Program to concatenate of two strings without using strcat function is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!