Short Note
Implement string copy function STRCOPY (str1,str2) that copies a string str1 (source) to another string str2 (destination) without using library function.
Advertisement Remove all ads
Solution
#include<stdio.h>
#include<conio.h>
void main()
{
char s1[100],s2[100],i;
clrscr();
printf(“enter string s1: “);
scanf(“%s”,s1);
for(i=0;s1[i]!=’\0’;++i)
{
s2[i]=s1[i];
}
s2[i]=’\0’;
printf(“string s2: %s”,s2);
getch();
}
Output:
Enter string s1:program
String s2: program
Concept: String
Is there an error in this question or solution?
Advertisement Remove all ads
APPEARS IN
Advertisement Remove all ads
Advertisement Remove all ads