Audiovox P965 Datový list Strana 233

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 280
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 232
API in C
230
stSentence->iLength = 0;
stSentence->iReturnValue = 0;
}
/********************************************************************
* Clear an existing sentence
********************************************************************/
void clearSentence(struct Sentence *stSentence)
{
DEBUG ? printf("initializeSentence\n") : 0;
free(stSentence->szSentence);
initializeSentence(stSentence);
}
/********************************************************************
* Add a word to a sentence struct
********************************************************************/
void addWordToSentence(struct Sentence *stSentence, char *szWordToAdd)
{
int iNewLength;
iNewLength = stSentence->iLength + 1;
// allocate mem for the new word position
if (stSentence->iLength == 0)
{
stSentence->szSentence = malloc(1 * sizeof stSentence->szSentence);
}
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;
}
Zobrazit stránku 232
1 2 ... 228 229 230 231 232 233 234 235 236 237 238 ... 279 280

Komentáře k této Příručce

Žádné komentáře