Pages

Saturday, 20 June 2015

User defined string copy function

User defined string copy function to copy one string to another string

Coding:

#include<stdio.h>
void mystrcpy(char *d,char *s)
{
int i;
for(i=0;(d[i]=s[i])!='\0';i++);
}

int main()
{
char b[30],a[30];
printf("Please enter the string:");
gets(b);
mystrcpy(a,b);
printf("Value in destination=%s",a);
return 0;
}

Output:
Please enter the string:Programming
Value in destination=Programming