31. Copying content of string in another string without using string function.


Comments

  1. Pandhare Dipali11:31 AM

    /*copy one string into another string*/
    #include
    #include
    #include
    void main()
    {
    char str1[10],str2[10];
    int i;
    printf("\n\t Enter first string:");
    gets(str1);
    printf("\n\t Enter second string:");
    gets(str2);
    printf("\n\t strings are before coping first string=%s,second string=%s:",str1,str2);
    for(i=0;i<=9;i++)
    {
    str2[i]=str1[i];
    }
    printf("\n\t strings are after coping first string=%s \n\tsecond string=%s:",str1,str2);
    }

    ReplyDelete
  2. #include
    #include
    void main()
    {
    char s1[100],s2[100];
    int i=0;
    printf("enter 1st string=\n");
    gets(s1);
    printf("enter 2nd string=\n");
    gets(s2);
    printf("befor coping....\n 1st string=%s\n2nd string=%s",s1,s2);
    for(i=0;i<=99;i++)
    {
    s2[i]=s1[i];
    }
    printf("\nafter coping....\n 1st string=%s\n2nd string=%s",s1,s2);
    }

    ReplyDelete
  3. Swati Waghmare11:38 AM

    /*copy first string into another sting*/
    #include
    #include
    void main()
    {
    char str1[10],str2[10];
    int i;
    printf("\n\tEnter first string");
    gets(str1);
    printf("\n\tEnter second string");
    gets(str2);
    printf("\n\tBefor copying first string=%s \n\tsecond string=%s",str1,str2);
    for(i=0;i<=9;i++)
    {
    str2[i]=str1[i];
    }
    printf("\n\tAfter copying first string=%s \n\t second string=%s",str1,str2);
    }

    ReplyDelete
  4. /* copy one string into another string*/
    #include
    #include
    void main()
    {
    char s1[10],s2[10];
    int i;
    printf("enter the 1st string--");
    gets(s1);
    printf("enter the 2nd string--");
    gets(s2);
    printf(" \n Before copy---- \n 1st string=%s \t 2nd string=%s \t",s1,s2);
    for (i=0; i<=9;i++)
    {
    s2[i]=s1[i];
    }
    printf(" \n After copy \n 1st string=%s \t 2nd string=%s \t",s1,s2);
    }

    ReplyDelete
  5. poonam pusavale11:41 AM

    /*copy one string into another string*/
    #include
    #include
    void main()
    {
    char s1[10],s2[10];
    int i;
    printf("\n\t enter first string");
    gets(s1);
    printf("\n\t enter second string");
    gets(s2);
    printf("\n\t before copy first string=%s , second string=%s",s1,s2);
    for(i=0;i<=9;i++)
    {
    s1[i]=s2[i];
    }
    printf("\n\t after copy first string=%s,second string=%s",s1,s2);
    }

    ReplyDelete
  6. Dipali Kore11:52 AM

    //copy the content of one file into another file
    #include
    #include
    void main()
    {
    FILE *fp1,*fp2;
    char ch;
    fp1=fopen("abc","r");
    if(fp1==NULL)
    {
    printf("\ncant open file");
    exit(1);
    }
    fp2=fopen("*xyz","w");
    if(fp2==NULL)
    {
    printf("\ncant open a file");
    exit(2);
    }
    while(ch|=EOF)
    {
    ch=fgetc(fp1);
    fputc(ch,fp2);
    }
    printf("\nfile opened succesfully");
    fclose(fp1);
    fclose(fp2);
    }

    ReplyDelete
  7. Dipali Kore11:59 AM

    /*copy first string into another sting*/
    #include
    #include
    void main()
    {
    char str1[10],str2[10];
    int i;
    printf("\n\tEnter first string");
    gets(str1);
    printf("\n\tEnter second string");
    gets(str2);
    printf("\n\tBefor copying first string=%s \n\tsecond string=%s",str1,str2);
    for(i=0;i<=9;i++)
    {
    str2[i]=str1[i];
    }
    printf("\n\tAfter copying first string=%s \n\t second string=%s",str1,str2);
    }

    ReplyDelete
  8. sonali nagane12:03 PM

    /*copy first string into another sting*/
    #include
    #include
    void main()
    {
    char str1[10],str2[10];
    int i;
    printf("\n\tEnter first string");
    gets(str1);
    printf("\n\tEnter second string");
    gets(str2);
    printf("\n\tBefor copying first string=%s \n\tsecond string=%s",str1,str2);
    for(i=0;i<=9;i++)
    {
    str2[i]=str1[i];
    }
    printf("\n\tAfter copying first string=%s \n\t second string=%s",str1,str2);
    }

    ReplyDelete
  9. Bhanvase Yashoda12:25 PM

    /*copy one str to another*/
    #include
    #include
    void main()
    {
    char s1[8];char s2[8];
    int i,j;
    printf("\n\tenter str ");
    gets(s1);
    printf("\n\t enter str");
    gets(s2);

    printf("Before copy s1=%s,s2=%s",s1,s2);

    for(i=0;i<=7;i++)
    {
    s2[i]=s1[i];
    }

    printf("after copy s1=%s,s1=%s",s1,s2);







    }

    ReplyDelete
  10. Bhosale Dhanashri SE310:27 AM

    // copy one string into another string


    #include
    #include
    void main()
    {
    char str1[10]="DHANASHRI";
    char str2[10]="BHOSALE";
    int i=0;
    printf("\n\t string before copy str1=%S,str2=%s",str1,str2);
    for(i=0;i<=10;i++)
    {

    str2[i]=str1[i];
    }

    printf("\n\t After copying str1=%s,str2=%s",str1,str2);


    }

    ReplyDelete
  11. mubin pirjade11:00 AM

    /* PROGRAM TO COPY ONE STRING INTO ANOTHER STRING */
    # include
    # include
    void main( )
    {
    char str1[10], str2[10];
    int i=0;
    printf("\n Enter first string:");
    scanf("%s", str1);
    printf("\nEnter second string:");
    scanf("%s",str2);
    printf("\n Before copying First string= %s and Second string=%s",str1,str2);
    for(i=0;i<=9;i++)
    {
    str2[i]=str1[i];
    }
    printf("\nAfter copying");
    printf("\nFirst string= %s Second string=%s",str1,str2);
    }

    ReplyDelete
  12. sachita jadhav11:16 AM

    /* copy of string */
    #include
    #include
    #include
    void main()
    {
    char str1[10],str2[10];
    int i;
    printf("enter first string");
    gets(str1);
    printf("enter second string");
    gets(str2);
    for(i=0;i<=9;i++);
    {
    str2[i]=str1[i];
    }
    printf("\n after copy first string =%s second string=%s",str1,str2);
    }

    ReplyDelete
  13. Awate Snehal11:57 AM

    /*copy string into another string*/
    #include
    #include
    void main()
    {
    char s1[10],s2[10];
    int i=0;
    printf("\n\t enter 1st string");
    gets(s1);
    printf("\n\t enter 2nd string");
    gets(s2);
    printf("before copy 1st string s1=%s,2nd string s2=%s",s1,s2);
    for(i=0;i<=9;i++)
    {
    s2[i]=s1[i];
    }
    printf("After a copying s1=%s,s2=%s",s1,s2);
    }

    ReplyDelete

Post a Comment