forked from b-k/21st-Century-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcetology.c
31 lines (29 loc) · 1016 Bytes
/
cetology.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Suggested makefile:
----------
P=cetology
CFLAGS=`pkg-config --cflags glib-2.0` -g -Wall -std=gnu99 -O3
LDLIBS=`pkg-config --libs glib-2.0`
objects=fstr.o string_utilities.o
$(P): $(objects)
----------
*/
#include "fstr.h"
int main(){
fstr_s *fstr = fstr_new("moby");
fstr_list chapters = fstr_split(fstr, "\nCHAPTER");
for (int i=0; i< chapters.count; i++){
fstr_list for_the_title=fstr_split(chapters.strings[i],"\\.");
fstr_show(for_the_title.strings[1]);
fstr_list me = fstr_split(chapters.strings[i], "\\WI\\W");
fstr_list whales = fstr_split(chapters.strings[i], "whale(s|)");
fstr_list words = fstr_split(chapters.strings[i], "\\W");
printf("\nch %i, words: %i.\t Is: %i\twhales: %i\n", i, words.count-1,
me.count-1, whales.count-1);
fstr_list_free(for_the_title);
fstr_list_free(me);
fstr_list_free(whales);
fstr_list_free(words);
}
fstr_list_free(chapters);
fstr_free(fstr);
}