Function to copy one string to another without using strcpy() function
#include <stdio.h>
#include <conio.h>
int main()
{
void copyString(const char *src, char *dest);
char str1[100];
char str2[100];
printf("Enter the string: ");
gets(str1);
copyString(str1, str2);
printf("Copied string: %s\n", str2);
getch();
}
void copyString(const char *src, char *dest)
{
while (*dest++ = *src++);
}
Comments
Post a Comment