blob: 70e5cd6d564511f16d333dfc66578750eda4d896 (
plain) (
tree)
|
|
int steviloZnakov (char * niz, char znak) {
int r = 0;
while (*niz) {
if (*niz++ == znak)
r++;
return r;
}
#include <string.h>
char * kopirajDoZnaka (char * niz, char znak) {
strchr(niz, znak)[0] = '\0';
char * r = strdup(niz);
niz[strlen(niz)][0] = znak;
return r;
}
char ** razcleni (char * besedilo, char locilo, int * stOdsekov) {
char * p = besedilo;
char ** r = NULL;
*stOdsekov = 0;
while (1) {
if (*p == locilo || !*p) {
*p = '\0';
r = realloc(r, ++*stOdsekov*sizeof *r);
r[*stOdsekov-1] = strdup(besedilo);
besedilo = p+1;
if (!*p)
return r;
}
p++;
}
}
|