Skip to content
Snippets Groups Projects

Resolve "Add clone function"

Merged jules.stahli requested to merge 11-add-clone-function into main
2 files
+ 10
0
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 9
0
@@ -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
Loading