c - Cut out section of a string with another string -


i got part of c program:

#include <stdio.h> #include <string.h> #include <stdlib.h>  int main(void){     char *mrna = spleissen("auaguaaaagcucuguuuaggaga", "gu", "ag");     printf("mrna: %s\n", mrna);     free(mrna);     return 0; } 

i have write function spleissen should work this: cuts out string goes gu ag , in between two. program output is:

mrna: auacucugaga 

i don't know how can cut parts out.

i not allowed use includes other stdio, string , stdlib.

char *spleissen(const char *src, const char *start, const char *end){     size_t len = strlen(src);     char *s, *e, *ret, *work;      ret = work = malloc(len + 1);     strcpy(work, src);     len = strlen(end);      while(s = strstr(work, start)){         if((e = strstr(s, end))==null)             break;//delete upto last?         memmove(s, e + len, strlen(e+len)+1);         work = s;     }     return ret; } 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -