Write a C program to Copy the string without using strcpy() function

In this article you will learn how to copy a string without using strcpy( ) function or standard library function.

Write a C program to Copy the string without using strcpy() function

Answer:

Note:

If you are unable to see whole code then open this page in desktop mode.

#include<stdio.h>
#include<conio.h>
int main()
{
  char str1[];
  char str2[];
  int i;
  printf("\n Enter the string");
  scanf("%s",str1[]);
  for(i=0;str1[i]!='\0';i++)
  {
    str2[i]=str1[i];
  }
    str1[i]='\0';
    printf("\n Now str1 is copy in str2,str2=%s",str2[]);
    getch();
    return 0;
}
Post a Comment (0)
Previous Post Next Post