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 ...@@ -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 the list is empty, point head to new node
if (temp == NULL) { if (temp == NULL) {
*ptrHead = newNode; //Point the head to the new node *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 newNode->next = NULL; //Set the new node next to NULL
return; return;
} }
...@@ -92,8 +91,10 @@ void AddPokemonToList(struct Pokedex pokedex,char name[], char type[], char abil ...@@ -92,8 +91,10 @@ void AddPokemonToList(struct Pokedex pokedex,char name[], char type[], char abil
return; return;
} }
temp->next = newNode; //Set the next pointer of the old last node to new node *ptrHead = newNode; //Set pointer to head to point to newNode
newNode->prev = temp; //Set the prev pointer of the new node to the old last node 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) { ...@@ -145,6 +146,8 @@ int main (void) {
AddPokemonToList(pokedex,"Squirtle","Water","WaterBlast"); AddPokemonToList(pokedex,"Squirtle","Water","WaterBlast");
AddPokemonToList(pokedex,"Squirtle","Water","WaterBlast"); //Testing that it doesnt add a duplicate AddPokemonToList(pokedex,"Squirtle","Water","WaterBlast"); //Testing that it doesnt add a duplicate
AddPokemonToList(pokedex,"The grass one","Leaf","LeafSomething"); AddPokemonToList(pokedex,"The grass one","Leaf","LeafSomething");
AddPokemonToList(pokedex,"Poki1","Leaf","LeafSomething");
AddPokemonToList(pokedex,"Poki2","Leaf","LeafSomething");
printf("%p\n",FindPokemon(pokedex,"Charmander")); printf("%p\n",FindPokemon(pokedex,"Charmander"));
...@@ -152,4 +155,3 @@ int main (void) { ...@@ -152,4 +155,3 @@ int main (void) {
return 0; 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