The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [c]

C is a general-purpose computer programming language used for operating systems, games, and other high performance work and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.

113 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10
votes
0answers
171 views

Tournament data structure

I have written a generic code for implementing a Tournament with c language. i have written all the documentation with Doxygen standard and kept it in header file, also I have written a unit test ...
10
votes
0answers
211 views

Code to fill PE import address table

I wrote a program to test AV engines against encryption. When it runs, it will compute some key, decrypt an executable it has in its data section and copy it to the locations where the executable ...
9
votes
0answers
897 views

Bilinear interpolation using Neon intrinsics

I'm trying to do a Bilinear interpolation on the ARM Neon. However, I find that my vectorized code is slower than the regular one, on a BeagleBone Black. Any idea why this could happen? I'm using ...
8
votes
0answers
314 views

Red-black tree appears to be slower than std::multimap

I've written a red-black tree in C as an exercise. The tree works and it is not bad, but it is about 10% slower than std::multimap from libstdc++ which I'm ...
7
votes
0answers
90 views

Engineering an even faster qsort

I understand that C++ STL template sort runs faster than qsort in C because ...
7
votes
0answers
87 views

Error handling function (Win32/C)

I have written the following function to be a general "error logging" solution for my Windows API projects. Basically, given a Windows system error code (a la ...
6
votes
0answers
66 views

Console arkanoid in C

On an Internet forum a person came with their homework, to write Arkanoid in a console - it seemed they wanted someone to do their homework for them so I did not respond. However, I found the task ...
6
votes
0answers
305 views

C - fully threaded binary search trees

For learning purposes, I've decided to implement several classic data structures, starting with binary search trees. The entire code can be seen here, in a frozen branch ...
6
votes
0answers
112 views

Bidirectional bijective hash map in C

I have this bidirectional hash map in C for dealing with bijective maps. Each key mapping consists of a primary key and a secondary key, and I can ask the data structure to give me a secondary key ...
6
votes
0answers
112 views

Positioning a file pointer with MPI I/O

This toy code uses MPI I/O to read from a binary file. It goes through reading: an ASCII header the first 10 doubles from an array of 100 ...
6
votes
0answers
489 views

Gauss-Seidel+SOR

I am learning OpenMP+MPI hybrid programming. As an example I have chosen Gauss-Seidel+SOR. My implementation uses MPI_THREAD_FUNNELED style hybrid programming, ...
5
votes
0answers
40 views

C clone of Hackertyper.net

This is a simple C clone of the website hackertyper.net. The code can be found on Github and is reproduced below: Makefile ...
5
votes
0answers
6k views

Implementation of Single Layer Perceptron Learning Algorithm in C

I have implemented a working version of perceptron learning algorithm in C. Right now, it only works on single layer perceptrons and only takes two inputs. I plan on making it work with more than two ...
5
votes
0answers
58 views

Yet another quicksort

Code review my quicksort! It isn't supposed to be superfast or anything and doesn't basecase out to insertion sort or anything. It's optimized for clarity and only sorts arrays of pointers. ...
5
votes
0answers
207 views

Cache conscious SIMD matrix multiply of unsigned integers

The goal of the code review by order of importance (i.e. What I hope to hear from you): I've verified correctness using a straightforward matrix multiply function though I am open to those who want ...
5
votes
0answers
698 views

Reusing curl easy handles in C

In a C project I want to reuse curl easy handles. The flow of program is like: Client --> C Application --> Call URL1, do something, Call URL2, do something, Call URL3... In short, for each client ...
5
votes
0answers
38 views

Variation of the internal PHP hashtable

I'm working on a PHP extension in an attempt to learn some C. I've implemented a variation of the internal PHP hashtable, which uses a lookup table and a separate bucket table. The lookup table simply ...
4
votes
0answers
70 views

Generic Macro Generated Interval Heap in C

When I saw this amazing data structure I couldn't stop myself from trying it! I first sought resources such as this and an article about it here. It basically works as a Max-Heap and a Min-Heap at the ...
4
votes
1answer
101 views

Hashtable implementation in C for generic values

I am trying to implement a hashtable that supports character keys and can return any type of value contained in a struct as long as it contains as long as it contains ...
4
votes
0answers
85 views

Memory managment for RPC code in C

My team has been given care of an old embedded C project. Its main part is a security critical RPC API and I'm trying to create a new design of its internal interfaces to make it more robust against ...
4
votes
0answers
144 views

Fast Hardy-Weinberg equilibrium simulation

I was very bored over one of my breaks this year, so I built a Hardy-Weinberg equilibrium simulator for two unrelated alleles of the same gene. Hardy-Weinberg equilibrium is when there is no evolution,...
4
votes
0answers
349 views

Linux GPIO rotary encoder as volume control

I've written a kernel module (tested on Raspberry Pi) to use a rotary encoder as a volume control. The Linux source tree already contains a driver for rotary encoders so I've just piggybacked off of ...
4
votes
0answers
68 views

General Purpose C Dictionary

I'm trying to create a general purpose C dictionary (as an opaque data type) capable of dynamically allocating basic types (ints, floats, strings and longs) as well as accepting void pointers to ...
4
votes
0answers
224 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 ...
4
votes
0answers
44 views

Texplode KotH controller

I am creating a KotH (King of the Hill) challenge for Programming Puzzles and Code Golf. Other site users will write programs that play Texplode (a version of this game on a square grid). The program ...
4
votes
0answers
209 views

Time Limit Exceeded with shortest path algorithm

The problem: SHPATH You are given a list of cities. Each direct connection between two cities has its transportation cost (an integer bigger than 0). The goal is to find the paths of ...
4
votes
0answers
203 views

SSE optimisation for audio resampling

I'm learning SSE for the first time and trying to optimise some code. Using oprofile shows that the CPU usage in this function went down from 2.5% to 0.9% using the ...
3
votes
0answers
73 views

Emulating a C++ enum class C++ in C

I am trying to emulate a C++ enum class in C and the code works as I expect. I used this code as indicated on Stack Overflow. ...
3
votes
0answers
55 views

Striping a matrix concentrically, anticlockwise

Given a matrix you shall stripe the matrix, such that every number that has equal distance to the matrix border will be filled into an array. For examples see code comments. ...
3
votes
0answers
66 views

Generic Makefile for C projects

I'm trying to create a generic Makefile that will work with the following directory structure: Project Directory Makefile main.c source file source directory Source files include directory Header ...
3
votes
0answers
183 views

K&R Exercise 1-13. Printing histogram of word lengths (vertical variant)

I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it. How does the following solution look to you? Note that, for the sake of exercise, I don't want to use ...
3
votes
0answers
57 views

Library for managing CLI flags

I'm pretty new to C, started learning it less than a month ago, the only language I had previous experience was Javascript. Anyways, I wrote a library for dealing with CLI flags. It's not a serious ...
3
votes
0answers
63 views

Print a list of disk blocks used by file(s) - Linux

This code takes a list of filenames as arguments or from stdin (or from a provided file) and dumps a list of disk blocks used by those files. An attempt is made to use the linux ...
3
votes
0answers
154 views

Eliminating chain rules from context-free grammars

I'm writing a small C program for elimination of chain rules from a context-free grammar. My idea is to rewrite the rules of the grammar in a specific useful order: making groups of productions that ...
3
votes
0answers
404 views

Complex multiplication and integration with CUDA

I want to perform multiplication on two vectors and integrate it in a vector called acc_y. The acc_y variable will update over ...
3
votes
0answers
771 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 ...
3
votes
0answers
78 views

Minimum number of basic operations to convert str1 into str2

I am to convert a given string into another using only three basic operations, that is by deleting, inserting or replacing a character. Changes can only be made to string 1 and it is given that the ...
3
votes
0answers
53 views

Find spanning tree with maximum edges with the same weight

For my university assignment I need to come up with an algorithm to find a spanning tree with maximum number of edges with same weight. I received an algorithm suggestion in this Stack Overflow answer....
3
votes
0answers
5k views

OpenSSL Client/Server

I have recently begun to dabble with OpenSSL to provide TLS encryption to TCP socket communication. Through documentation and heavy reference on example code I have come up with the following code (...
3
votes
0answers
404 views

Attempt at multithreaded memory allocator

I'm trying to learn C and memory management, therefore as an exercise I've written a memory allocator. I've taken the best fit algorithm and added multithreading with locks. I'm a beginner with ...
3
votes
0answers
131 views

Random number generation

I'm trying to port some MonteCarlo code to CUDA (this is my first CUDA experience). The CPU code often calls a function which generates a random number: ...
3
votes
0answers
244 views

Simple virtual machine prototype for Lisp-style languages

I found a post I made here an year ago (Compiler for a minimal LISP dialect to run on the Java Virtual Machine) and got interested on this subject again. This time I decided to implement the ...
3
votes
0answers
49 views

Fast lock implementation using pipes only

For fun I wanted to create a lock implementation that was about as fast as one using futexes but that used used pipes instead and that queues waiters in user space instead of in-kernel. For the queue ...
3
votes
0answers
872 views

Mutex implementation without built-ins

I want to implement simplest mutex without built-in functions or the <pthread.h> module. ...
3
votes
0answers
210 views

Linux performance using multi-threads (vs one thread) and ssh message

My server receives requests in one thread and responds in another. I am using thread pools of pthread-s for both receiving and sending. The performance is not that bad, however... When I am doing the ...
3
votes
0answers
467 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 ...
3
votes
0answers
144 views

Reduce encoded length of UTF-8 encoded Ruby string in C extension

I'm writing a Ruby extension in C. It's a string processing module working on UTF-8 encoded strings only. One method, full_width_to_ascii!, converts full width ...
3
votes
0answers
191 views

CUDA program that emulates a kind of cellular automata slower on the GPU than on the CPU

I'm a very new to CUDA, so I'm still trying to understand how to make the best use of the GPU. I've ported a C algorithm to it. This algorithm works by loading the memory with an initial input, then ...
3
votes
0answers
211 views

Parallel reduction by key implementations

I have an implementation of the reduction approach used in this document. Furthermore, I extended (crudely) this so I can reduce-by-key. In my setup I can assume that a ...
3
votes
0answers
71 views

A version of the Pebble Big Time watch face that also displays the date

I'm seeking style pointers, bugs, memory leaks, incorrect usage etc. ...