
API in C
231
/********************************************************************
* Add a partial word to a sentence struct...useful for concatenation
********************************************************************/
void addPartWordToSentence(struct Sentence *stSentence, char *szWordToAdd)
{
int iIndex;
iIndex = stSentence->iLength - 1;
// reallocate memory for the new partial word
stSentence->szSentence[iIndex] = realloc(stSentence->szSentence[iIndex], strlen(stSentence->szSentence[iIndex]) + strlen(szWordToAdd) + 1);
// concatenate the partial word to the existing sentence
strcat (stSentence->szSentence[iIndex], szWordToAdd);
}
/********************************************************************
* Print a Sentence struct
********************************************************************/
void printSentence(struct Sentence *stSentence)
{
int i;
DEBUG ? printf("Sentence iLength = %d\n", stSentence->iLength) : 0;
DEBUG ? printf("Sentence iReturnValue = %d\n", stSentence->iReturnValue) : 0;
printf("Sentence iLength = %d\n", stSentence->iLength);
printf("Sentence iReturnValue = %d\n", stSentence->iReturnValue);
for (i=0; i<stSentence->iLength; i++)
{
printf(">>> %s\n", stSentence->szSentence[i]);
}
printf("\n");
}
/********************************************************************
* MD5 helper function to convert an md5 hex char representation to
* binary representation.
Komentáře k této Příručce