Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void izbaci(char* string, char* podstring)
- {
- int i = 0;
- char* indeks = strstr(string,podstring);
- int duzinaPodstringa=strlen(podstring);
- while ((indeks != NULL) && (*(indeks) != '\0'))
- {
- if ((*(indeks-1) == ' ') && (*(indeks+duzinaPodstringa) == ' ' || *(indeks+duzinaPodstringa) == '\0'))
- {
- while ( *(indeks+i) != '\0')
- {
- *(indeks+i) = *(indeks+i+duzinaPodstringa);
- i++;
- }
- *(indeks+i) = *(indeks+i+duzinaPodstringa);
- }
- i = 0;
- indeks++;
- indeks = strstr(indeks,podstring);
- }
- }
- int main()
- {
- char string[] = "test ovu izbaci";
- izbaci(string, "ovu");
- puts(string);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment