This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:data:spring2024:projects:mpg2 [2024/02/29 04:45] – [malloc] rspringe | notes:data:spring2024:projects:mpg2 [2024/02/29 04:49] (current) – [singly-linked list] rspringe | ||
---|---|---|---|
Line 12: | Line 12: | ||
Since a linked list is a series of " | Since a linked list is a series of " | ||
+ | |||
+ | The same also applies for removing elements. Once an element has been removed from a linked list, the memory can be freed so it can be used elsewhere, if needed. | ||
=====malloc===== | =====malloc===== | ||
Since this project deals with linked lists and dynamically adding and removing elements from a list, malloc will still need to be used to allocate memory. | Since this project deals with linked lists and dynamically adding and removing elements from a list, malloc will still need to be used to allocate memory. | ||
Line 21: | Line 23: | ||
functionForAddingElement(args) { | functionForAddingElement(args) { | ||
- | struct* newStruct = (struct*)malloc(sizeof(struct)) | + | struct* newStruct = (struct*)malloc(sizeof(struct)); |
| | ||
// Place Data into New Struct | // Place Data into New Struct |