Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Program implementat de Nan Mihai
- Pregatire examen restanta PC - 2014
- */
- char *strdel(char *p, int n) {
- char *aux = strdup(p + n);
- strcpy(p, aux);
- return p;
- }
- char *strins(char *p, char *s) {
- char *aux;
- aux = strdup(p);
- strcpy(p, s);
- strcat(p, aux);
- return p;
- }
- int main() {
- char text[100], cuv1[100], cuv2[100], *p, *aux;
- gets(text);
- gets(cuv1);
- gets(cuv2);
- p = strstr(text, cuv1);
- while(p)
- {
- aux = p;
- strdel(aux, strlen(cuv1));
- strins(aux, cuv2);
- aux += strlen(cuv2);
- p = strstr(aux, cuv1);
- }
- printf("%s", text);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment