【发布时间】:2023-03-13 14:21:02
【问题描述】:
我正在尝试做一个项目来检查列表中的单词是否重复,但它看到 AuxLista 总是将 temp-palavra 返回为 null?
void AuxLista(Lista *L, char tmp_word) {
if (!L) return;
Lista *temp = L;
printf("\n");
while (temp != NULL)
{
if(temp->palavra == tmp_word){
printf("%s Está repetida. ", temp->palavra);
}
printf("TESTE %s", temp->palavra);
temp = temp->prox;
}
}
Lista *criarLista(char *word){
Lista *result = malloc(sizeof(Lista));
AuxLista(result, word);
result->palavra = word;
result->prox = NULL;
if (result->NOCORRENCIAS == NULL) result->NOCORRENCIAS = 1;
else result->NOCORRENCIAS = result->NOCORRENCIAS + 1;
return result;
}
- 列表项
【问题讨论】: