Enter string copy string without using strcpy

Write a program to enter the user define string and copy string without using strcpy () function.


Source Code:

#include<stdio.h>
#include<conio.h>
void main()
{
	char a[20],b[20];
	int i;
	clrscr();
	printf("Enter the String:");
	gets(a);
	for(i=0;a[i]!=NULL;i++)
	{
		b[i]=a[i];
	}
	b[i]=NULL;
	printf("Given string is:%s",b);
	getch();

}

Output:

Enter the String: Bhavesh Jain

Given string is: Bhavesh Jain

Leave a Reply

Your email address will not be published. Required fields are marked *