Guardar palabras distintas en la lista vinculada
Básicamente tengo 2 listas vinculadas aquí: lista y distinta. Hay algunos conjuntos de palabras que se han guardado anteriormente en la estructura 'lista'. Iba a escribir un programa que encontraría las palabras que son distintas / únicas y las guardaría en la estructura 'distinta'. Aquí está lo que obtuve hasta ahora basado en mi concepto en los punteros. Sin embargo, cuando intento imprimir "distinto", el programa falla :( corríjame si me equivoco.
struct list {
char string[50];
struct list *next;
};
struct distinct {
char string[50];
struct distinct *next;
};
void checkdistinct() {
list *ori = NULL;
distinct *copy = NULL;
distinct *check = NULL;
if(ori == NULL && copy == NULL) { //first time.
ori = ori->next;
copy = copy->next;
copy = (distinct*)malloc(sizeof(distinct));
strcpy(copy->string, ori->string);
ori = ori->next;
copy = copy->next;
}
else {}
while(ori!=NULL) {
check = check->next;
while(check != NULL) {
if(strcmp(ori->string, check->string)!=0) {
check = check->next;
}
else {
ori = ori->next;
check = NULL;
}
}
//only compare same casing words, for now.
copy = (distinct*)malloc(sizeof(distinct));
strcpy(copy->string, ori->string);
ori = ori->next;
copy = copy->next;
}
}
Cuando intente imprimir en la página principal, se bloqueará :( responda si necesita comentarios adicionales para los códigos. ¡Gracias!