WAP to copy the string

Write a program to copy the string without using string function

#include<stdio.h>
#include<conio.h>

void copy(char[],char[]);

int main() {
	char a[100],b[100];

	printf("Enter a string:\n");
	gets(a);
	copy(b,a);
	printf("Copied string = %s\n",b);
	getch();
	return 0;
}

void copy(char q[],char p[]) {
	int i=0;
	while(p[i]!='\0'){
		q[i] = p[i];
		i++;
	}
	q[i] = '\0';
}

Output

Enter a string:
nawaraj
Copied string = nawaraj

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments