/*string cpy */
#include "stdio.h"
char *stringcpy(char *str_des,const char *str_src);
int main()
{
char str_des[40];
char str_src[20];
printf("\nEnter the first string\n");
scanf("%s",str_des);
printf("\nEnter the second string\n");
scanf("%s",str_src);
stringcpy(str_des,str_src);
printf("\nstring copy is done:The first string is : %s \n", str_des);
return(0);
}
char *stringcpy(char *str_des,const char *str_src)
{
char *temp= str_des;
while(*temp!='\0')temp++;
while(*str_src != '\0')*temp++ = *str_src++;
*temp = '\0';
return str_des;
}
No comments:
Post a Comment