Advertisement Remove all ads

Implement String Copy Function Strcopy (Str1,Str2) that Copies a String Str1 (Source) to Another String Str2 (Destination) Without Using Library Function. - Structured Programming Approach

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
Share
Notifications

View all notifications


      Forgot password?
View in app×