slicing a string

 #include <stdio.h>

char slice(char *st,int m, int n)
{

    int i=0;
    while((i+m)<n)
    {
        st[i]=st[i+m];
        i++;
    }
   st[i]='\0';
}

int main(){
char str[]="Anchalanaya";

slice(str,1,8);
printf("The sliced string is:%s\n",str);
 return 0;
}

Comments

Popular posts from this blog

snake game Version-2 (using random number)

allocating dynamic memory using calloc

store a table in dynamic array and then change the size of array dynamically to store more numbers