Skip to content
Snippets Groups Projects
Commit 0d0772c5 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

Merge branch '11-add-clone-function' into 'main'

* Added clone function

Closes #11

See merge request !13
parents 94a4d62f 166b49ca
Branches
Tags
1 merge request!13Resolve "Add clone function"
......@@ -16,3 +16,12 @@ void stack_peek(stack s, int *value){
*value = s.data[s.top];
}
}
void stack_clone(stack s, stack *clone) {
clone->top = s.top;
clone->capacity = s.capacity;
clone->data = malloc(sizeof(int) * s.capacity);
for (int i = 0; i <= s.top && i < s.capacity; i++) {
clone->data[i] = s.data[i];
}
}
\ No newline at end of file
......@@ -10,5 +10,6 @@ typedef struct _stack {
void stack_init(stack *stack);
void stack_peek(stack s, int *value);
void stack_clone(stack s, stack *clone);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment