Copy of the string,string copy,C string copy,find string copy,copy of the string using pointers,find copy of the string in
C, Write a program to copy of the given string using pointers
in C language,string copy program,find string copy using pointers
in C,find strlcpy()
String Copy
In this program,the given source string is copied into destination string.
#include<stdio.h>
void stringcopy(char *,char *);
main()
{
char source[100],destination[100];
printf("Enter String\n");
scanf("%[^\n]",source);
stringcopy(source,destination);
printf("After copy the string is : %s\n",destination);
}
void stringcopy(char *str1,char *str2)
{
while(*str1 != '\0')
{
*str2 = *str1;
*str1++;
*str2++;
}
*str2 = '\0';
}
Output:
Enter String
Welcome to C
After Copy the string : Welcome to C
String Copy
In this program,the given source string is copied into destination string.
#include<stdio.h>
void stringcopy(char *,char *);
main()
{
char source[100],destination[100];
printf("Enter String\n");
scanf("%[^\n]",source);
stringcopy(source,destination);
printf("After copy the string is : %s\n",destination);
}
void stringcopy(char *str1,char *str2)
{
while(*str1 != '\0')
{
*str2 = *str1;
*str1++;
*str2++;
}
*str2 = '\0';
}
Output:
Enter String
Welcome to C
After Copy the string : Welcome to C
0 comments:
Post a Comment