Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
Loading...
Searching...
No Matches
word_count.h
1#ifndef WORD_COUNT_H
2#define WORD_COUNT_H
3
4#define MAX_WORDS 20 // at most MAX_WORDS can be found in the test input string
5#define MAX_WORD_LENGTH 50 // no individual word can exceed this length
6
7// results structure
8typedef struct word_count_word
9{
10 char text[MAX_WORD_LENGTH];
11 int count;
13
14#define EXCESSIVE_LENGTH_WORD -1
15#define EXCESSIVE_NUMBER_OF_WORDS -2
16
17// word_count - routine to classify the unique words and their frequency in a
18// test input string inputs:
19// input_text = a null-terminated string containing that is analyzed
20//
21// outputs:
22// words = allocated structure to record the words found and their frequency
23// uniqueWords - number of words in the words structure
24// returns a negative number if an error.
25// words will contain the results up to that point.
26int word_count(const char *input_text, word_count_word_t *words);
27
28#endif
Definition word_count.h:9