-->
Showing posts with label WAp to concatenate two strings. Use no arguments and return its output.. Show all posts
Showing posts with label WAp to concatenate two strings. Use no arguments and return its output.. Show all posts

WAp to concatenate two strings. Use no arguments and return its output.

in turboc++
-----------------------------------------------------------------------------------------------------------

//WAP to concatenate two  strings using(strcat()) function.Pass no parameters and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcat();//prototype of function(must as pointer)
int main()
{
    printf("merged string=%s\n",stringcat());//prints with calling
     getch();
    return 0;
}
char *stringcat()
{
    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

   
    return strcat(name,name1);//returning the concatenated string
}









----------------------------------------------------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------------------------------------------
//WAP to concatenate two  strings using(strcat()) function.Pass no parameters and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcat();//prototype of function(must as pointer)
int main()
{
    printf("merged string=%s\n",stringcat());//prints with calling
     getch();
    return 0;
}
char *stringcat()
{
    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

   
    return strcat(name,name1);//returning the concatenated string
}