Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Napisati funkciju char** rem_word(char** s,
- char* w) koja uklanja sve pojave reči w iz niza
- reči s i vraća pokazivač na niz reči iz kojeg su
- izbačene pojave reči w.*/
- #include <stdlib.h>
- #include <string.h>
- char** rem_word(char** s, char* w) {
- if(!w) return s;
- char **pos = s, **old_s = s;
- while(s && *s) {
- if(strcmp(*s, w))
- *pos++ = *s;
- else free(*s);
- s++;
- }
- if(old_s) {
- *pos = *s; //NULL
- old_s = realloc(old_s,
- sizeof(*old_s) * (pos - old_s + 1));
- }
- return old_s;
- }
Advertisement
Add Comment
Please, Sign In to add comment