in turboc++
---------------------------------------------------------------
//WAP to copy a string using(strcpy()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcpy(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); //string input
printf("copied string=%s\n",stringcpy(name1,name));//prints with calling
getch();
return 0;
}
char *stringcpy(char string[],char string1[])
{
strcpy(string,string1);
return string;
}
---------------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------
//WAP to copy a string using(strcpy()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcpy(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); //string input
printf("copied string=%s\n",stringcpy(name1,name));//prints with calling
getch();
return 0;
}
char *stringcpy(char string[],char string1[])
{
strcpy(string,string1);
return string;
}
---------------------------------------------------------------
//WAP to copy a string using(strcpy()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcpy(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); //string input
printf("copied string=%s\n",stringcpy(name1,name));//prints with calling
getch();
return 0;
}
char *stringcpy(char string[],char string1[])
{
strcpy(string,string1);
return string;
}
---------------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------
//WAP to copy a string using(strcpy()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcpy(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); //string input
printf("copied string=%s\n",stringcpy(name1,name));//prints with calling
getch();
return 0;
}
char *stringcpy(char string[],char string1[])
{
strcpy(string,string1);
return string;
}