S-11 - * If the word does not fit, then do nothing. */ void...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
pw = (Word *)malloc(sizeof(Word)); if (pw == NULL) Fatal("Out of memory after %d candidates\n", cpwCand); return pw; } /* wprint -- print a word, followed by a space * * We would normally just use printf, but the string being printed is * is a huge pointer (on an IBM PC), so special care must be taken. */ void wprint(char * pch) { printf("%s ", pch); } PWord NextWord(void); /* NextWord -- get another candidate entry, creating if necessary */ PWord NextWord(void) { PWord pw; if (cpwCand >= MAXCAND) Fatal("Too many candidates\n", 0); pw = apwCand[cpwCand++]; if (pw != NULL) return pw; apwCand[cpwCand-1] = NewWord(); return apwCand[cpwCand-1]; } /* BuildWord -- build a Word structure from an ASCII word
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: * If the word does not fit, then do nothing. */ void BuildWord(char * pchWord) { unsigned char cchFrequency[ALPHABET]; int i; char * pch = pchWord; PWord pw; int cchLength = 0; bzero(cchFrequency, sizeof(unsigned char)*ALPHABET); /* Zero(cchFrequency); */ /* Build frequency table */ while ((i = *pch++) != '\0') { if (!isalpha(i)) continue; i = ch2i(tolower(i)); if (++cchFrequency[i] > alPhrase[i].uFrequency) return; ++cchLength; } Debug(wprint(pchWord);) /* Update global count */ for (i = 0; i < ALPHABET; i++) auGlobalFrequency[i] += cchFrequency[i]; /* Create a Word structure and fill it in, including building the * bitfield of frequencies. */...
View Full Document

Page1 / 2

S-11 - * If the word does not fit, then do nothing. */ void...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online