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.

117 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
207 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. ...
3
votes
0answers
54 views

Calculating OpenGL view matrices

I'd like a little help here calculating the view matrix for OpenGL based on the lookat type function: ...
3
votes
0answers
877 views

Defining a char device driver protocol over uart at kernel level

My aim is to write a blocking char driver that return to the user space a complete protocol message from the kernel uart driver. Protocol description I'm fighting with a very bad protocol, called ...
2
votes
2answers
69 views

Production-ready comparison between byte-array and ByteBuffer

I want to compare the performance difference between using byte[] and ByteBuffer in Java, which approach I should use in my ...
2
votes
0answers
38 views

Blocking serial port C library

I am planning to write a reasonably feature rich serial library but wanted to cut my teeth on something fairly basic. This serial library is fairly simple. It is a thin wrapper on the UNIX open, ...
2
votes
0answers
36 views

Simple Socket Server in C for Windows

I have taken the code from a tutorial of Microsoft webpage. Of course, the example is for illustration only but I wanted to organize it and make it clear in order to understand it a little more. Here ...
2
votes
0answers
53 views

Taskbar for X11 using Athena widgets

I am developing a simple taskbar for X11 using the Athena widgets. The current code is very limited: it assumes an EWMH-compliant window manager and only adds the initially running windows to the ...
2
votes
0answers
50 views

Simple generic macro-generated containers

In order to learn macros in C I decided to make a generic data structures generator for other projects that I have in C. The main macros are the following: ...
2
votes
0answers
36 views

Getting an element from RCU-protected list in kernel

I wrote a function, read_fox_rcu() for getting an element from RCU-protected list in a linux device driver. read_fox_rcu() reads ...
2
votes
0answers
66 views

CUDA kernel to compare matrix entries, weighted with a pattern

I wonder if it's possible to optimize this code in CUDA. Could I get any hints how to? Equivalent algorithm runs faster in Matlab for me, but there I'm doing matrix operations. Compution I'm not ...
2
votes
0answers
382 views

Max flow Ford-Fulkerson using DFS augmented path retrieval

I have written a naive max flow with DFS, could anyone review my below code. What can be done to improve the code and what are the worst cases where this won’t work acceptably? ...
2
votes
0answers
260 views

Simple Neural Network in C

A neural network is a structure of connections and nodes that takes input and generates an output. It can be "taught"(adjusting weights and biases of connections) from a teacher data set with ...
2
votes
0answers
98 views

Lock-free statically allocated async-interrupt-safe multi-consumer double buffer

I have a single threaded embedded system with nested interrupts. A writer interrupt will periodically update some global data structure with data. Reader interrupts / calls from main thread will read ...
2
votes
0answers
108 views

WinAPI 32 wrapper in C

This is a piece of code using this wrapper to create a simple window and handle some of it's events in Windows environment. ...
2
votes
0answers
60 views

Parse Mach-O binding info

I wrote this C program to open a Mach-O executable/framework and parse the external symbols along with their respective framework/library. A few things I would like to get better at: Memory ...
2
votes
0answers
292 views

IPC reader-writer without starvation

I'm trying to implement a functional version of the classic reader-writer problem in IPC which doesn't cause starvation. You can find the full article here The code is working. What do you think, is ...
2
votes
0answers
133 views

Changing window buffer and size in C with WinAPI

I wrote a code to change window buffer and size in a console app with C. Background: I had trouble with changing window buffer and size in C with WinAPI. Simply calling system("mode con cols=XX lines=...
2
votes
0answers
56 views

intersection of two arrays

I have written a logic to find out the intersection of two arrays. Please review my logic and guide me if my logical approach is not correct. ...
2
votes
0answers
51 views

Lex simple line-counting grammar

I'm trying to make a lex (flex) grammar that kicks out tokens while always being aware of the current line number. As an exercise, I made a simple grammar that accepts raw strings ...
2
votes
0answers
595 views

Thread-safe rand for C

I have this very short program for dealing with thread-safety of C's rand. Is it a correct implementation? ...
2
votes
0answers
352 views

Convert FoxPro/dBase DATETIME field to Win32 SYSTEMTIME struct

I'm trying to write a complete driver for Visual FoxPro's DBF format for Win32. I found that the way that fields of the DATETIME type are stored in dBase files is ...
2
votes
0answers
87 views

Yet Another Linked List

I've been populating my git with some old code, and I came across this linked list I wrote about 10-12 months ago. I'm wondering just how thread safe it is and if there are any improvements I can make ...
2
votes
0answers
648 views

Wrapper/abstraction for encryption and decryption using OpenSSL

I am a beginner when it comes to cryptography and OpenSSL. I have written a short wrapper of some functions in OpenSSL as well as a test of this wrapper, copied below. Specifically, this code is ...
2
votes
0answers
54 views

Updating a table when a process ends

I have the following piece of code. I would like to be able to combine my first big block if statement inside my while loop and clean up my usage of variables since I'm doing a lot of setting. I've ...
2
votes
0answers
64 views

2016 Advent of Code Day 2, Part 1 and Part 2

Continuing from yesterday, here's a simple solution in C to part 1 of Advent of Code Day 2. I used a simple state machine to map from each keypad key to the next keypad key given the input. ...
2
votes
0answers
171 views

libconfini (shared library)

I recently wrote a small INI parsing library. The code is also on GitHub, with documentation. I would like to have opinions, suggestions, and critiques. confini.h ...
2
votes
0answers
299 views

Multithreaded C program to calculate CPU usage of cgroups

I am writing a program in an environment that makes use of cgroups to identify and group processes together. I want to parse the CPU utilization of each cgroup by sampling ...
2
votes
0answers
1k views

Parallel Hillis-Steele Scan using CUDA

I'm learning CUDA (and C to some extent), and one of the algorithms that I am learning is the Hillis-Steele scan algorithm. I wrote a program that performs a simple scan with adding. After seeding ...
2
votes
0answers
108 views

MPI BMP image comparison

I made a simple program in which I compare two images pixel by pixel and determine if the pictures are the same. I'm trying to adapt it to MPI, but I'm afraid that the communications are taking too ...
2
votes
0answers
74 views

Convert tri-gram of type wchar_t to an integer type

I am trying to convert a tri-gram containing 3 characters of type wchar_t to an integer type (an uint64_t at the present time). ...
2
votes
0answers
68 views

N Processing connect to a single process: Socket Programming

The idea of my program is to use pthreads, semaphores, posix shared memory, and sockets to create an environment where N processes (that we will refer to as the children) can connect to a single ...
2
votes
0answers
212 views

Windows AppLocker extension - Owner rule

I am trying to extend Windows AppLocker behavior to add custom rule which checks owner of executables in Program Files and Windows folders. This would help us patch folders that are writable by ...
1
vote
1answer
77 views

Fixed-Size Floating-Point Types

I have created my own personal data structure libraries for C and I've re-engineered it about two times now and I've added alot of preprocessor checks and defines concerning OS type and compiler type. ...
1
vote
0answers
38 views

Prompting the user to input a data value into an element in a linked list

I'm working through a practice problem that is having me build and modify a linked list over a series of steps. I am particularly interested in knowing if there's a more elegant way of prompting the ...
1
vote
0answers
26 views

Sort an array of strings using bubble sort

I have this following code to sort an array of strings order by ASCII value (alphabetically) using bubble sort. ...
1
vote
1answer
67 views

Find the sum of the digits of a given number

I need to find the sum of the digits of the given number and repeat the process until the value lies between 1 to 9. e.g if the input is 72457 then, 7+2+4+5+7 = 25 2+5 = 7 so , the function ...
1
vote
0answers
35 views

Convolutions with shared memory in CUDA

I am writing a noise blur convolution kernel in CUDA ...
1
vote
0answers
48 views

C Generic Sorted Doubly-Linked List

I just finished this big project. Its is called SortedList and it is implemented using a Doubly-Linked List. It data is of type ...
1
vote
0answers
68 views

selecting 5 best players out of 2 team

Let us assume that we need to develop an application which can select best 11 players to score maximum points. The application will select the best players after completion of a match. The rules are ...
1
vote
0answers
95 views

Neural Network Backpropagation

My neural network is buggy somewhere. However, the reason I am posting here and not Stack Overflow is because a buggy neural network can still be trained to some degree and will compile/perform better ...
1
vote
0answers
86 views

System on Chip Validator

With reference to my source files, published in the git repository soc-testing I did my best effort at coding, based on 30 years of experience, so I would like to know what I did wrong with my ...
1
vote
0answers
77 views

Simple overlapped IO single threaded client

I wanted to make a single threaded network client that only uses a single connection to a server. IOCP seems like overkill but overlapped IO with event notification I think is the most performant of ...
1
vote
0answers
121 views

GLSL Simplex Noise with derivatives

I recently made 2d simplex noise based coherent noise in GLSL. [Here] is the shader toy. I wanted to make an implementation of simplex noise on the gpu in order to get better performance than the CPU ...
1
vote
0answers
87 views

Server Client in socket c

This is a lib I am doing to interact with sockets. :) Here is the main file: ...
1
vote
0answers
34 views

Sending AT commands via switch case in Arduino

Is this the proper use for switch case? I am looking to make a simple utility for reporting back Wireless AP info, Baud Rate, and Mode of a ESP8266 module. When the program loads it gives the user a ...
1
vote
0answers
144 views

Matlab and WidowX robot arm communication and control

For a class, we needed to control the WidowX arm from Trossen Robotics from Matlab and get as real-time of a feedback as possible. So I came up with a code for the Arbotix Robot-controller which is ...
1
vote
0answers
424 views

Deletion of Word from Ternary Search Tree where Both Siblings Present

This code review will require somewhat a more indepth look at the code operation (at least it did for me) to understand the two word deletion areas and the node rotation and frees I'm most concerned ...
1
vote
0answers
65 views

Computing butterflies with better performance

I have a code that computes butterflies and from a little profiling I found out that it is a little bit slow. So, it seemed that the better way to optimize its performance is vectorizing it using ...
1
vote
0answers
77 views

Fetch value from website using cURL

I want to make a http request, get the website content and check one specific element. Currently I'm doing it with lcurl (got explanations from a tutorial). Here is an excerpt of my code: ...