Subscribe Us

Responsive Advertisement

Advertisement

deletion of substring in c without built in function

 

deletion of substring in c without built in function 



#include<stdio.h>

void delet(char s[],int n,int le)

{


    if(n+le>strlen(s))

    {

        printf("invalid index or length");

        return ;

    }

    else

    {    // abcdef  2 3

        for(int i=n+le-1;i<strlen(s);i++) s[i-le]=s[i];

        s[strlen(s)-le]='\0';

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


    }

}



int main()

{


    int p,l;

    char a[100];

    gets(a);

    scanf("%d%d",&p,&l);

    delet(a,p,l);


    return 0;

}


Post a Comment

0 Comments