Thursday, 6 September 2012

/* --- Program on String Concatenation --- */


#include <stdio.h>
#include <conio.h>
main()
{
    char str1[100],str2[100],str3[100];
    int i,j;

    clrscr();
    gotoxy(15,2);
    printf("Program on String Concatenation\n");
    gotoxy(5,5);
    printf("Enter Family (Sur)Name : ");
    gets(str1);
    gotoxy(5,7);
    printf("Enter your Name : ");
    gets(str2);
    gotoxy(5,9);

/*    Concatenation procedure    */

/*    Str1 is copied onto Str3    */
    for(i=0;str1[i]!='\0';i++)
        str3[i]=str1[i];

/*    Str2 is copied to ending of Str3    */

    for(j=0;str2[j]!='\0';j++)
        str3[j+i]=str2[j];


    str3[j+i]='\0';    /* Assigning a Null to end */

    printf("Your Full Name is : ");
    puts(str3);
    getch();
}

No comments:

Post a Comment