fix: 🐛 creating local array causes unreliability

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-07-08 23:48:13 +03:00
parent 441fca3e2d
commit 5b6cb7af0b
2 changed files with 113 additions and 12 deletions

View file

@ -11,17 +11,6 @@ struct Stack {
};
Stack new() {
Stack stack;
stack.top = -1;
stack.size = STACK_SIZE;
int elements[STACK_SIZE];
stack.elements = elements;
return stack;
}
int push(Stack* stack, int element) {
if (stack->top +1 > stack->size) {
return -1;
@ -61,7 +50,12 @@ int search(Stack* stack, int element) {
int main() {
printf("Hello World\n");
Stack stack = new();
Stack stack;
stack.top = -1;
stack.size = STACK_SIZE;
int elements[STACK_SIZE];
stack.elements = elements;
push(&stack, 123);
push(&stack, 5);