Skip to content

Instantly share code, notes, and snippets.

@Silva97
Created May 28, 2018 15:56
Show Gist options
  • Save Silva97/9b50b6f2776aeb32765dda1429121177 to your computer and use it in GitHub Desktop.
Save Silva97/9b50b6f2776aeb32765dda1429121177 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define MAX_STACK 64
typedef struct stack {
int value[MAX_STACK];
int size;
} Stack;
void push(Stack *s, int value);
int pop(Stack *s);
int main(){
Stack pilha = {.size = 0};
push(&pilha, 25);
push(&pilha, 32);
printf("> %d\n", pop(&pilha));
printf("> %d\n", pop(&pilha));
return 0;
}
void push(Stack *s, int value){
s->value[ s->size++ ] = value;
}
int pop(Stack *s){
s->size--;
return s->value[ s->size ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment