Skip to content

init commit Array Toua#69

Open
txiong000 wants to merge 4 commits intobloominstituteoftechnology:masterfrom
txiong000:master
Open

init commit Array Toua#69
txiong000 wants to merge 4 commits intobloominstituteoftechnology:masterfrom
txiong000:master

Conversation

@txiong000
Copy link
Copy Markdown

No description provided.

// Throw an error if the index is greater than the current count

if (index > arr->count) {
fprintf(stderr, "IndexError: Index %d out of range\n", index);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job with this error message.


free(arr->elements);
// Free array
free(arr);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This destroy method looks great!

arr->capacity = capacity;
arr->count = 0;
// Allocate memory for elements
arr->elements = malloc(capacity * sizeof(char *));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants