Wednesday, 19 February 2014

write a program to copy one string to other string using function .(without use of predefined library function).


/* write a program to make a function to copy a string*/
#include<stdio.h>
#include<stdio.h>
char*fstrcpy(char*,char*);
main()
{
char s1[100],s2[100],*p,temp[100]={0};
puts("enter first string:");
gets(s1);
puts("enter the second string:");
gets(s2);
p=s1;
p=fstrcpy(p,s2);
printf("%s",p);
}  // end of main function

char*fstrcpy(char*s1,char*s2)
{
int i,n;
n=strlen(s1);
for(i=0;i<n;i++)
{        
                            
s1[i]=s2[i];
}

return s1;
}

No comments:

Contact Form

Name

Email *

Message *