Write a program in C language to copy a string without using the library function.
#include<stdio.h>
#include<conio.h>
// function to copy a string
void strcopy(char s1[50], char s2[50])
{
int i=0;
while(s[1i]!='\0')
{
s2[i]=s1[i];
i++;
}
s2[i]='\0';
}
int main()
{
char str1[50],str2[50];
clrscr();
printf("Enter the source string\n");
gets(str1);
strcopy(str1,str2);
printf("Destination string is\n");
puts(str2);
getch();
}
Output:
Enter the source string
Mukesh
Destination string is
Mukesh
Post A Comment:
0 comments: