What I would do is
- Have a function that would count the number of Nodes in the list.
- Have this number in the recursive function
- Have a loop that would move a temporary pointer to the last one in the list
// function call
reversingList(number,primaryPointer,newPointer,counter,0);
// function definition
void reversingList(int number,Node *primaryPointer,Node *newPointer,int counter);
{
static Node *temp = primaryPointer;
static Node array[number];
if ( number == 0 )
{
while ((*temp).GetNextNodePtr() != NULL )
{
(*temp) = array[counter];
temp = (*temp).GetNextNodePtr();
}
// Assigning to a new list
while ( counter != 0 )
{
temp = new Node(array[counter]);
newPointer = temp;
newPointer = (*newPointer).GetNextNodePtr();
counter --;
}
(*newPointer).SetNextNodePtr(NULL); // assign last ptr to NULL
}
if ( number != 0 )
{
counter++;
reversing(number-1,primaryPointer,counter);
}
} Best Regards,
aphrodita@mail.krovatka.ru {uiuc rules}