Created
November 2, 2014 20:41
-
-
Save jleeothon/5fcc7d98191a2b8449f0 to your computer and use it in GitHub Desktop.
Simple stack in C
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
/* for any stack in the form... */ | |
int _s[100]; | |
int *s = _s; /* top of the pending stack (this location empty) */ | |
/* be very careful about passing expressions for a stack, not well guarded */ | |
#define isempty(s) ((s) - (_s)) | |
#define push(s, v) (*s++ = (v)) | |
#define pop(s) (*(--s)) | |
#define peek(s) ((s)[-1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment