Skip to content
Snippets Groups Projects
Commit 66130f6e authored by richarda.tyarks's avatar richarda.tyarks
Browse files

add function stack_push

parent 6e8cc6fa
Branches
No related tags found
1 merge request!7add function stack_push
This commit is part of merge request !7. Comments created here will be created in the context of that merge request.
# stack
# ohayo onii chan !
stack.c 0 → 100644
#include "stack.h"
void stack_push(stack *s, int val)
{
if (s->top == s->capacity-1)
{
assert(s->data = realloc(s->capacity * 2 * sizeof(int)) && "Error : realloc failed");
}
s->top++;
s->data[s->top] = val;
}
\ No newline at end of file
#ifndef _STACK_H_
#define _STACK_H_
typedef struct _stack {
int *data;
int capacity;
int top;
} stack;
void stack_push(stack *s, int val);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment