String copy without using strcpy().

                    String copy without using strcpy():  

   Hello ,readers in this blog you will come across the concept of                                                               string copy without using strcpy() function.
   
   strcpy() function is default inbuilt function that copy one string into another string .
   But the below code will copy one string into another string without using strcpy() function.
   





https://programminghub1999.blogspot.com/2018/12/string-copy-without-using-strcpy.html

    


                                     Following method has used in programme



  1.  Take input string from user
  2. Run the iteration till the length of first string.
  3. Copy the first string into other string.
  4. Then put null value at the end of second string.




                            Copy one string into other string



#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    clrscr();
    char str1[30],str2[30];
    int i,j;
    printf("Enter string\n");
    gets(str1);
    j=0;
   for(i=0;i<str1[i]!='\0';i++)
    {
         str2[j]=str1[i];
         j++;
    }
     str2[j]='\0';
     printf("String after copy is");
     puts(str2);
     getch();
}

Thank's you enjoyed the code .Please comment on this blog.

   

         
    
String copy without using strcpy(). String copy without using strcpy(). Reviewed by Deepak kumar soni on December 25, 2018 Rating: 5

No comments:

Powered by Blogger.