-->

Wap to concatenate two strings.Pass string as parameter and return the result.

in turboc++
--------------------------------------------------------------------------------
//WAP to concatenate two  strings using(strcat()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcat(char string[],char string1[]);//prototype of function(must as pointer)
int main()
{
    char name[100],name1[100];// declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//can be used
    gets(name); //first string input
    printf("enter second string\n");
    gets(name1);//second string input
    printf("merged string=%s\n",stringcat(name,name1));//prints with calling
     getch();
    return 0;
}
char *stringcat(char string[],char string1[])
{
    strcat(string,string1);
    return string;
}










------------------------------------------------------------------------------------------------------
in codeblocks:
-------------------------------------------------------------
//WAP to concatenate two  strings using(strcat()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcat(char string[],char string1[]);//prototype of function(must as pointer)
int main()
{
    char name[100],name1[100];// declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//can be used
    gets(name); //first string input
    printf("enter second string\n");
    gets(name1);//second string input
    printf("merged string=%s\n",stringcat(name,name1));//prints with calling
     getch();
    return 0;
}
char *stringcat(char string[],char string1[])
{
    strcat(string,string1);
    return string;
}

No comments:

Post a Comment