#include "stdio.h"
#include "malloc.h"
#include "string.h"
#define MaxL 100+1
SubString(char Sub[MaxL],char Str[MaxL],int pos,int len)
{
for(int k=0;k<len;k++)
{
//if((pos+k-1)>strlen(Str)-1) break;
if(!Str[pos+k-1]) break;
else
Sub[k]=Str[pos+k-1];
}
Sub[k]='/0';
}
IndexString(char Str[MaxL],char Sub[MaxL],int &pos)
{
int l1=strlen(Str);
int l2=strlen(Sub);
if(l2==0) return (pos=0);
char Sub1[MaxL];
for(int k=1;k<l1-l2+1;k++)
{
if (pos==0) break;
SubString(Sub1,Str,k,l2);
if(strcmp(Sub1,Sub)==0) --pos;
}
if(k<l1-l2+1) pos=k-1;
else
pos=0;
}
InsString(char Str[MaxL],int pos,char Sub[MaxL])
{
int l1=strlen(Str);
if(pos>l1) strcat(Str,Sub);
else
{
char Sub1[MaxL];
SubString(Sub1,Str,pos,MaxL);
Str[pos-1]='/0';
strcat(Str,Sub);
strcat(Str,Sub1);
}
}
DelString(char &Str[MaxL],int pos,int len)
{
if(pos+len>strlen(Str))
Str[pos-1]='/0';
else
{
char Sub1[MaxL];
SubString(Sub1,Str,pos+len,MaxL);
Str[pos-1]='/0';
strcat(Str,Sub1);
}
}
void main()
{
char *str="1234567890StringABCD";
int pos=10;
int len=6;
DelString(str,pos,len);
//str[10]='/0';
printf("/n%s/n",str);
}