Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Pokedex_Assignment
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
a-j.towse
Pokedex_Assignment
Commits
556f2259
Commit
556f2259
authored
Jan 02, 2023
by
a-j.towse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working Add and find pokemon
parent
8916b496
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
main
main
+0
-0
main.c
main.c
+10
-5
No files found.
main
View file @
556f2259
No preview for this file type
main.c
View file @
556f2259
...
...
@@ -90,12 +90,14 @@ void AddPokemonToList(struct Pokedex pokedex,char name[], char type[], char abil
}
/*
while (temp->next != NULL) {
while
(
temp
->
next
!=
NULL
)
{
//If pokemon already exists in the list, do nothiing
if
(
strcmp
(
temp
->
name
,
newNode
->
name
)
==
0
)
{
return
;
}
}*/
temp
=
temp
->
next
;
printf
(
"%s
\n
"
,
temp
->
name
);
}
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
...
...
@@ -105,13 +107,15 @@ void AddPokemonToList(struct Pokedex pokedex,char name[], char type[], char abil
struct
PokemonNode
*
FindPokemon
(
struct
Pokedex
pokedex
,
char
name
[])
{
PokemonNode
*
temp
=
pokedex
.
ptrToPokemonHead
;
PokemonNode
**
ptrHead
=
pokedex
.
ptrToPokemonHead
;
PokemonNode
*
temp
=
*
ptrHead
;
while
(
temp
->
next
!=
NULL
)
{
while
(
temp
!=
NULL
)
{
if
(
strcmp
(
temp
->
name
,
name
)
==
0
)
{
return
temp
;
}
temp
=
temp
->
next
;
}
}
...
...
@@ -130,6 +134,7 @@ int main (void) {
//NewPokemonNode("Charmander","Fire","FireBallz");
AddPokemonToList
(
pokedex
,
"Charmander"
,
"Fire"
,
"FireBallz"
);
AddPokemonToList
(
pokedex
,
"Squirtle"
,
"Water"
,
"WaterBlast"
);
//printf("%p\n",FindPokemon(pokedex,"Charmander"));
printf
(
"%p
\n
"
,
FindPokemon
(
pokedex
,
"Squirtle"
));
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment