Commit 21a92d6c authored by a-j.towse's avatar a-j.towse

Fixed printPokiList function - all commented

parent 5fd507f3
No preview for this file type
......@@ -83,7 +83,6 @@ void AddPokemonToList(struct Pokedex pokedex,char name[], char type[], char abil
//If the list is empty, point head to new node
if (temp == NULL) {
*ptrHead = newNode; //Point the head to the new node
newNode->prev = NULL; //Set the new node prev to NULL
newNode->next = NULL; //Set the new node next to NULL
return;
}
......@@ -92,8 +91,10 @@ void AddPokemonToList(struct Pokedex pokedex,char name[], char type[], char abil
return;
}
temp->next = newNode; //Set the next pointer of the old last node to new node
newNode->prev = temp; //Set the prev pointer of the new node to the old last node
*ptrHead = newNode; //Set pointer to head to point to newNode
newNode->next = temp; //Set newNode to point to old first item in list
newNode->prev = NULL; //Set the prev pointer to NULL as is first item in list
temp->prev = newNode; //Set temp to point to new first item in list (newNode)
}
}
......@@ -145,6 +146,8 @@ int main (void) {
AddPokemonToList(pokedex,"Squirtle","Water","WaterBlast");
AddPokemonToList(pokedex,"Squirtle","Water","WaterBlast"); //Testing that it doesnt add a duplicate
AddPokemonToList(pokedex,"The grass one","Leaf","LeafSomething");
AddPokemonToList(pokedex,"Poki1","Leaf","LeafSomething");
AddPokemonToList(pokedex,"Poki2","Leaf","LeafSomething");
printf("%p\n",FindPokemon(pokedex,"Charmander"));
......@@ -152,4 +155,3 @@ int main (void) {
return 0;
}
//List node not listing squirtle for some reason... fix me
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment