Subscribe Us

Responsive Advertisement

Advertisement

insertion string in c without built in function

 

insertion string in c without built in function



#include<stdio.h>

void insert(char s1[],int r,char s2[])

{

    char s[500];

    r--;

    int i,j;

    for(i=0,j=0;i<strlen(s1);i++,j++)

    {

        if(r==i)

        {

            char c=s1[i];

           for(int k=0;k<strlen(s2);k++)

           {

               s[j]=s2[k];

               j++;

           }


        }



            s[j]=s1[i];



    }

s[j]='\0';

    printf("%s\n",s);

}

int main()

{

    char a[100],b[100];

    gets(a);

    int n;

    scanf("%d",&n);

    char c;

    scanf("%c",&c);

    gets(b);

    insert(a,n,b);



    return 0;

}


Post a Comment

0 Comments