Datasheet
API in C using winsock
72
else
{
stSentence->szSentence = realloc(stSentence->szSentence, iNewLength * sizeof stSentence->szSentence + 1);
}
// allocate mem for the full word string
stSentence->szSentence[stSentence->iLength] = malloc(strlen(szWordToAdd) + 1);
// copy word string to the sentence
strcpy(stSentence->szSentence[stSentence->iLength], szWordToAdd);
// update iLength
stSentence->iLength = iNewLength;
}
/********************************************************************
* 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);










