All Questions
71 questions
2
votes
2
answers
102
views
Generic stack implementation (revision)
The below post is a follow-up of Generic stack implementation.
Below follows a header-only implementation of a generic stack (inspired by stb-libraries, following these guidelines: stb-howto.txt). ...
3
votes
1
answer
214
views
Generic stack implementation
The provided code (a header-only library inspired by stb libraries] defines functions for creating a stack, pushing elements onto the stack, popping elements from the stack, peeking at the top element ...
0
votes
4
answers
812
views
Stack using doubly linked list
I have implemented my stack based on a doubly linked list. The code is tested and works; however, I am interested in any improvement ideas.
...
0
votes
3
answers
163
views
Simple stack of integers
I've a simple push/pop implementation in my program:
...
2
votes
0
answers
67
views
C Finding strongly connected graph components in linear time using Kosaraju's algorithm
I followed this algorithm to find strongly connected graph components in C and this code works (I think ... maybe there are bugs I am not aware of). I am wondering can I please get some feedback? ...
2
votes
1
answer
85
views
A (Sort of) Generic Stack Implementation in C using Macros
I spent some time implementing a generic stack in C using macros. Apart from general bugs and bad practices in my code, I was wondering about the viability of an implementation like this that uses ...
2
votes
2
answers
75
views
Basic Stack Operations using Linked List in C
I have made a few functions for some basic stack operations using linked lists. Please review my code and suggest some ways to increase its readability. I would also love to hear ideas on how to make ...
5
votes
2
answers
270
views
Stack implementation in C programming Language
I have tried to implement a Stack and associated functions in C, in order to understand the data structure better. Just wanted to know what do you think about my code overall.
Furthermore, I am using <...
7
votes
1
answer
378
views
Pseudo-Generic Array Stack in C
I have implemented an array based pseudo-generic stack in C using macros. The code works fine for all data types. Is it a good idea to implement such a data structure using macros?
array_stack.h
...
3
votes
2
answers
109
views
Stack API for generic values
I'm trying to create a stack library from scratch. It stores generic elements which are passed in void* pointers.
This is the defined structure:
...
7
votes
1
answer
2k
views
Calculator in C - Parsing arithmetic expression using the shunting-yard algorithm
This is a simple arithmetic calculator, which parses mathematical expressions specified in infix notation using the shunting-yard algorithm. This is one of my personal projects and I would love to ...
1
vote
1
answer
267
views
Stack of integers in C
I'm learning C, and currently I follows C99 standard. Here is my implementation of integer-stack, which is just a stack you can do: push, pop, and print the content ...
0
votes
1
answer
249
views
Generic stack implementation in C
I haven't separated the stack code into its own header and source yet, this is just a proof of concept for now. Haven't chosen better function names yet because I ultimately want to integrate this ...
6
votes
2
answers
656
views
Error Code Stack Trace and Propagation Library in C
I've been programming in Go and I enjoy how easy it is to create descriptive errors and propagate them up the call stack. I wanted that sort of ease and consistency in C so I created a small error ...
2
votes
2
answers
3k
views
Dynamic Array Based Stack in C
I wrote a dynamic stack in C that uses an array as a structure. I tried to maintain O(1) for push and pop and believe I have done so. I want to know what can be written in a cleaner way and if there ...
3
votes
2
answers
1k
views
Convert infix regular expression notation to postfix
This is a small part of a larger program for implementing a limited syntax regular expression constructor using Ken Thompson's construction algorithm. Converting to postfix before the regular ...
10
votes
2
answers
648
views
An attempt at a toy Vm
I usually use c++ so it may not be best practice for c.
This is a stack based toy vm and as a result it is very primitive, and it has no bitwise
instructions
64k might be a bit overkill for a toy vm.
...
7
votes
3
answers
367
views
Dynamic stack implementation in C
I've been studying C for a while, as a programmer coming from a C++ background, I'm used to the standard library, STL, etc., and I quickly realized that I need some kind of a containers library/data ...
3
votes
2
answers
4k
views
3
votes
3
answers
554
views
Stack implementation using linked-list
typedef struct Stack {
char v;
int x;
int y;
struct Stack* next;
} Stack;
Above is my stack struct.
...
4
votes
1
answer
72
views
C pointer based growable stack rev2
Following on from my previous question: C pointer based growable stack
I have made some improvements (hopefully!) based on the very helpful comments and suggestions.
I have checked that the stack can ...
7
votes
3
answers
1k
views
C pointer based growable stack
This is my first attempt at writing a C program, it a generic stack that can grow accordingly. It appears to work correctly, however I am worried that is just a fluke and I could be doing something ...
6
votes
5
answers
163
views
Safe stack abstraction
Here is the stack abstraction that I've written. I've designed it to be safe and without undefined behavior.
I use ugly_cast to discourage casting and to make ...
5
votes
3
answers
134
views
Unix tail command using stack
I'm working on a version of the Unix tail command that works by iterating over a file, pushing line by line into a stack. Finally, the number of desired lines will be popped and printed to the screen. ...
2
votes
3
answers
477
views
Implementing a stack using a linked-list
In my intro CS class we're reviewing data structures. I'm currently working on implementing a stack using a linked list (LIFO) in C. I'd appreciate a review of the implementation as well as of my ...
3
votes
2
answers
105
views
A Stack Implementation In C
I've written a very simple linked list based stack implementation and was wondering if this is the standard way to do it in C.
...
2
votes
2
answers
417
views
Converting prefix expressions to infix
Here is my new working code. Man, working with strings in C is tedious and annoying. I had built the algorithm in short time, took hours figuring how to implement it properly in C. Tell me if there ...
4
votes
1
answer
1k
views
Generic fixed-size Stack implementation in C
Coming mostly from C#/Java background, I'm trying to implement a simple fixed-size stack data structure in C. The main concern about the "fixed-size" part is that pushing new elements to a full stack ...
9
votes
4
answers
4k
views
Checking for parentheses balance in C
A recent assignment asks me to create a program that checks for parentheses balance in a given string. As I can't find any duplicate questions that have code written in C, I decided to post another ...
3
votes
1
answer
86
views
A C stack with minimum and maximum values
I have this C stack implementation that knows its minimum and maximum values:
minmax_stack.h
...
7
votes
3
answers
104
views
Minimal stack from unsigned int to track boolean values wtih bits
This grew out of a need to track sequential ctrl+shift+Left/Right-arrow keypress events on a gtk editor. It is a small stack implementation for boolean values (for <...
10
votes
1
answer
2k
views
Dynamic stack C implementation
I'm a C beginner. I'm studying and implementing some data structures. I'd like to get feedback.
This is a stack implemented with an dynamic array.
In main there ...
5
votes
2
answers
18k
views
FIFO, FILO, LIFO and LILO integer stacks in C
One of my current side projects includes a stack-based interpreter written in C for a programming language I'm designing, SSBL. Since the entire language is stack-based, I needed a way to create and ...
6
votes
2
answers
254
views
Stack and Queue Linked List Implementations
I'm relatively new to C as a language, but I wouldn't call myself a beginner. That being said, I don't believe my C "coding style," so to speak, is particularly developed. Also, I'm new to error ...
5
votes
2
answers
1k
views
Linked deque implementation in C
I wrote a deque implementation in C for storing char *. It uses a doubly linked list, but I'm calling it a deque since it can only push/pop from the head and tail ...
5
votes
1
answer
175
views
Concurrent stack in C - follow-up
This is a follow-up question to Concurrent stack in C
The pop function not just removes the top element from the stack, but also returns it.
If a pthreads call ...
7
votes
2
answers
928
views
Concurrent stack in C
(See also the follow-up question.)
I was in the mood for pthread.h and decided to write a concurrent stack data structure. My requirements:
the stack has maximum ...
2
votes
3
answers
174
views
Stack abstraction
Here is the Stack abstraction:
...
7
votes
2
answers
1k
views
Very simple stack in C
I'm starting to learn C and thought it would be a good idea to try and implement some data structures. I started with a very simple stack and would like to hear some opinions.
Stack.c
...
-1
votes
1
answer
102
views
Trying to build a bare metal stack on the stack [closed]
I'm trying to implement a stack data structure, but not on the heap but using the stack. Also not using any Node or Element struct but raw ints. Is this feasible? This is my code (with debug printfs) ...
4
votes
2
answers
142
views
Designing stack and queue from scratch in C
As a beginner and curious guy I'm interested in implementing data structures and algorithms from scratch. Here's my implementation of Stack and Queue, the most fundamental data structures.
Are ...
2
votes
1
answer
2k
views
Building a Stack with C structs
After reading the book from which this example is from I started using APIs like this
...
0
votes
1
answer
233
views
C stack for Linux and BSD
My stack uses char data and is not tested. I use it to save command in a unix pipeline for my own POSIX shell. Maybe you can find a bug or a possible improvement.
...
3
votes
1
answer
2k
views
Dynamic array stack and bag implementation
I've have methods for a stack and bag using a dynamic array in C. As far as I can tell everything is implemented correctly, but I'm wondering what I can do to improve this code.
dynArray.h
...
3
votes
1
answer
174
views
Simple stack structure in C
I just started to learn C, and for practicing, I tried to implement a simple stack data structure, and I want to know if I'm making any mistakes, or how could I improve it:
My stack.h:
...
4
votes
2
answers
272
views
C Stack data structure
I have implemented a Stack data structure in C and I would like to know if there is something that could be improved.
Stack using linked list:
...
8
votes
3
answers
8k
views
Simple Stack Implementation in C
This is my implementation of the stack data type in C language. It is static meaning it does not grow in size. Any suggestions or feedback would be much appreciated.
...
2
votes
1
answer
1k
views
Postfix evaluation using a stack in c
I have written a program to evaluate a postfix expression using a stack. I had my stack implementation using a linked list reviewed here, so I am only including the header file here.
I have taken ...
5
votes
2
answers
345
views
Stack implemented using a single linked list
I am studying data structures and I have implemented a stack using a linked list.
stack.h
...
5
votes
1
answer
161
views
ADT stack with a dynamic array (revision 1)
Here's the second draft of my ADT stack code which I posted here before after carrying out most of the improvements suggested there.
I decided to expose a function called ...