Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c99]

C99 is a standard for the C programming language. It replaces the previous C89 standard, and is succeeded by the C11 standard. C99 added inline functions, C++-style comments, allows intermingled declarations and code, as well as multiple other language and library fixes and additions.

4
votes
3answers
82 views

Linked List written in C

I have been learning data structures and dynamic memory allocation in C. As a learning experience, I have written this linked list implementation. I really appreciate the feedback I've received on the ...
4
votes
2answers
81 views

Hangman v2 written in C

This is a follow up to my previous Code Review, and I have incorporated feedback I received in this revision of the code, along with some other improvements. I would appreciate your feedback on this ...
3
votes
1answer
63 views

Hangman written in C

I would like your feedback on any improvements that can be made to this Hangman game I have written in C. Specifically, improvements in terms of runtime and code organization. This game was a nice way ...
2
votes
3answers
37 views

Command line test runner

This is a simple program to run a command-line program with given parameters and verify that it writes the expected output to stdout or stderr. The specification file is passed as the first argument. ...
2
votes
2answers
53 views

Parse IP address from a GPRS module reply

I'm writing a parser to get the IP address from a string I get from a GPRS module. Examples of the string I get from the GPRS module: +QIACT: 1,1,1,\"10.162.143.228\"\r\n\r\nOK\r\n +QIACT: 1,1,...
7
votes
2answers
137 views

Simple console JSON formatter

I am writing simple formatter for valid JSON. Is reads JSON data from stdin and writes formatted output to stdout. Goals: given valid input produce valid formatted JSON output constant memory usage ...
2
votes
0answers
470 views

A Thread-Safe FIFO in C99

I started a little weekend project to try and learn how to multithread with pure C99 and POSIX threads. The project is composed of three threads, input, processing, and output, which communicate with ...
4
votes
1answer
129 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 ...
1
vote
2answers
500 views

Function to scan input to string buffer in C

I have written a function that reads standard input, ignores initial whitespace and fills the buffer with that data. I think that it is a bit large and cumbersome, can you please tell me what can be ...
3
votes
3answers
81 views

Reading and classifying lines from a file

I'm new to C which I'm learning in university now, and I'm not sure if the following is considered in C good practices or not. For an assignment in a simple Classification problem I wrote the ...
3
votes
1answer
616 views

Sprite animation with SDL2

For the past few days I've been trying to learn how to animate 2D sprites using SDL2. For that purpose, I've taken a 6 frames animation from a Pokémon game and made a PNG image out of it : The way I ...
4
votes
0answers
158 views

Fast ray/triangle intersection code in C

I wonder if someone is familiar with ray/triangle intersection algorithms and can help me optimize them? Here are my implementations of two ray/triangle intersection algorithms in C. The first is the ...
7
votes
2answers
805 views

C - Generic ArrayList / Dynamic Array Implementations

As a small project to refresh my C and data-structure knowledge, I decided to write a generic ArrayList (as in Java). This is my most current version: ArrayList.h: ...
4
votes
2answers
119 views

File chunk buffer for Windows programs

The purpose of the ChunkBuffer code below is to designate a "chunk" from a given input file and to loop that chunk (if needed). Its operation is similar to the ...
6
votes
1answer
171 views

Counting sort implementation in C

I've just implemented counting sort in C and would like to hear your opinions on it. As I'm usually being rather picky when rating other people's code, please go ahead and be picky, too -- I will try ...
2
votes
2answers
115 views

IPC using pipes

I have simulated the conversation between a caller and receiver using fork and pipe. The parent process is the receiver and the child process is the caller. Each message is terminated by a newline. ...
5
votes
2answers
368 views

Dynamic Array container in macros

The code below is an attempt to mimic std::vector from the C++ standard library in the C language. The implementation is purely macros, in the C99 dialect, and ...
0
votes
1answer
45 views

colorprint - part 2

This is a followup of the last review to comply with meta's rules. In the last, I posted a small library called colorprint and got some helpful pointers from chux ...
3
votes
1answer
47 views

colorprint - An ANSI Escape sequence console writer mini-library

I wrote this a long time ago. I came back to it and decided to clean it up a little. It uses the preprocessor and C99 anon structs to make a flexible python-like ...
3
votes
0answers
328 views

Rust-like “Result” in C - nicer error handling

There are frequently things I miss when using C; one of them is a nice error-handling (exception-like) system. After trying Rust, I realized I could implement something similar in C itself. So here's ...
11
votes
3answers
477 views

Dijkstra's algorithm in C99

I just implement Dijkstra's algorithm in C99. Can you review my code please? I'm looking for any mistake, performance improvement or coding style errors. main.c ...
4
votes
1answer
48 views

YAGOP - Yet Another Generic Object Pool

While thinking about this question it struck me that one problem of linked data structures always seems to be loss of memory locality and performance could possibly be improved if all allocated nodes ...
6
votes
2answers
142 views

Implementation of the ls command with several options - follow-up 2

I've made more improvements from previous iterations and my own, including: Added the -n flag (print owner and group IDs instead of names) Eliminated some ...
11
votes
2answers
879 views

Implementation of the ls command with several options - follow-up

I've made vast improvements to my previous ls implementation, including: Added new flags: -g (omit owner listing) ...
18
votes
3answers
8k views

Implementation of the ls command with several options

As part of a past assignment, I've expanded on this implementation of ls to have more options available, including non-standard ones. It currently supports these (...
5
votes
1answer
121 views

Calculating diagonal difference

I was trying to solve a problem concerning the difference of the diagonal sums of a matrix (using C99): ...
2
votes
1answer
773 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
2answers
314 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 ...
3
votes
4answers
2k views

Simple singly linked list implementation in C

I have implemented a LinkedList with the ability to add, get elements from a particular position and ability to show all the elements in the array in to the console ...
5
votes
1answer
75 views

Program to tell which if any of three numbers is in the middle

I wrote this program, and it does what it asks, but it's so big and ugly. What can I change? Some examples: ...
4
votes
2answers
199 views

Low level string manipulation functions in C

I'm working with a legacy program that does a bunch of markup manipulation, some of it higher-level and specific to the proprietary markup, some of it lower level string stuff. I rewrote and ...
7
votes
2answers
155 views

Reverse engineering Darkstone game archives

Reverse engineering old games is something I do every now and then. This time, I took a shot at this old RPG called Darkstone. The bulk of the game's data is stored in archive files with the ...
6
votes
1answer
142 views

Simple procedural image patterns

I have these functions for generating procedural debug data for another piece of code related to image processing. The three following functions generate these simple mechanical patterns, which are ...
8
votes
4answers
1k views

Simple compression algorithm

An implementation of a simple compression algorithm that's featured in a programming practice book. My goals: Robust: All error conditions must be handled properly. The specification indicated in ...
4
votes
2answers
226 views

Algorithm (and tests) to parse lists of unsigned 32-bit ints from strings in C

What? I have an algorithm that parses comma separated lists of unsigned 32-bit ints from strings. Here is an example of what a list could look like: ...