Commit 57aa5b61 authored by elijah vasquez's avatar elijah vasquez 🦍

commitscreaming

parent a2560e32
......@@ -56,11 +56,19 @@ PlayerNode* ListPlayers(Pokedex* pokedex) {
}
// Create new pokemon node, return pointer to it
/*
initializes a pointer of type PokemonNode* to NULL,
then assigns it the memory allocated by malloc.
checks if the memory was successfully allocated before proceeding
to initialize the struct's fields with the parameters passed in
(name, type, ability) using the strcpy function.
Sets the next field to NULL and returns the newly created struct.
*/
PokemonNode* NewPokemonNode(char name[20], char type[20], char ability[30]) {
PokemonNode* newPoke = NULL;
newPoke = malloc(sizeof(PokemonNode));
PokemonNode* newPoke = NULL; // Pointer initalised
newPoke = malloc(sizeof(PokemonNode)); // Creation of dynamically allocated memory
if (newPoke != NULL) {
strcpy(newPoke->name, name);
strcpy(newPoke->name, name); //
strcpy(newPoke->type, type);
strcpy(newPoke->ability, ability);
newPoke->next = NULL;
......
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