Ciao a tutti!! Ho realizzato une funzione che
collega due liste concatenate.
Tutto funziona perfettamente e ho previsto anche
che una o entrambi le liste siano nulle.
Ma il codice mi sembra "astruso",
chi ha qualcosa di più intellegibile??
struct listNode {
char data;
struct listNode *nextPtr;
};
typedef struct listNode LISTNODE;
typedef LISTNODE * LISTNODEPTR;
...
...
void concatenate(LISTNODEPTR *firstList, LISTNODEPTR * secondList)
{
LISTNODEPTR currentPtr = *firstList;
if (*firstList == NULL)
*firstList = *secondList;
else
while (currentPtr != NULL &&
currentPtr->nextPtr != secondList )
if (currentPtr->nextPtr != NULL)
currentPtr = currentPtr->nextPtr;
else
currentPtr->nextPtr = *secondList;
}