Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
c_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
elijah vasquez
c_pokedex_assignment
Commits
57aa5b61
Commit
57aa5b61
authored
Jan 17, 2023
by
elijah vasquez
🦍
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commitscreaming
parent
a2560e32
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
main.c
main.c
+11
-3
No files found.
main.c
View file @
57aa5b61
...
@@ -56,11 +56,19 @@ PlayerNode* ListPlayers(Pokedex* pokedex) {
...
@@ -56,11 +56,19 @@ PlayerNode* ListPlayers(Pokedex* pokedex) {
}
}
// Create new pokemon node, return pointer to it
// 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
*
NewPokemonNode
(
char
name
[
20
],
char
type
[
20
],
char
ability
[
30
])
{
PokemonNode
*
newPoke
=
NULL
;
PokemonNode
*
newPoke
=
NULL
;
// Pointer initalised
newPoke
=
malloc
(
sizeof
(
PokemonNode
));
newPoke
=
malloc
(
sizeof
(
PokemonNode
));
// Creation of dynamically allocated memory
if
(
newPoke
!=
NULL
)
{
if
(
newPoke
!=
NULL
)
{
strcpy
(
newPoke
->
name
,
name
);
strcpy
(
newPoke
->
name
,
name
);
//
strcpy
(
newPoke
->
type
,
type
);
strcpy
(
newPoke
->
type
,
type
);
strcpy
(
newPoke
->
ability
,
ability
);
strcpy
(
newPoke
->
ability
,
ability
);
newPoke
->
next
=
NULL
;
newPoke
->
next
=
NULL
;
...
...
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