Created
May 28, 2018 15:56
-
-
Save Silva97/9b50b6f2776aeb32765dda1429121177 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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