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.

learn more… | top users | synonyms

-1
votes
0answers
16 views

Optimizing segment tree with lazy propagation [on hold]

I have solved this Flipping Coins problem using segment tree with lazy propagation. Here is my solution ...
1
vote
2answers
23 views

Classifying lexemes in a given C program

Please review my code and tell where I can improve my program. ...
4
votes
1answer
45 views

UTF-8 encoding/decoding

I have two functions, a collection of possible error codes, and a unit-testing framework. The parsing of a character into its unary prefix and payload is handled by a few named functions and macros ...
-3
votes
0answers
9 views

Scramble the string on the basis of index obtained by reversing its digits in binary form [on hold]

I am trying to solve this practice problem on Codechef and I am passing all the test cases I can think of, but I am still getting the wrong answer. I really want to learn which test case I missed. ...
2
votes
0answers
16 views

Tic Tac Toe dynamically changing board position and score board position

Here is my game logic: Tic Tac Toe - player Vs player Player A (first player to enter his name) is getting 'O' and is starting Players choose the desired spot to put their sign(X or O) using the ...
11
votes
3answers
659 views

Safe multiplication of two 64-bit signed integers

The function below implements safe multiplication of two 64-bit signed integers, preventing overflow from occurring: ...
9
votes
3answers
459 views

Daemonizer in C

I am aware that the malloc is a potential memory leak, but with an execvp coming, and that never returning. The purpose is to ...
1
vote
1answer
38 views

4D matrix math library for use with OpenGL

I am trying to create a simple library for C to handle OpenGL matrix operations. You can see the vec3fscalar here. ...
1
vote
1answer
35 views

Non-blocking Unix domain socket

I've developed quickly two kinds of socket use: the first with blocking mode and the second with non-blocking mode. The sockets are Unix domain sockets. My problem is that the kernel consume a huge ...
3
votes
2answers
41 views

LZW encoder and decoder

Recently, I reviewed this question about an LZW decoder. In order to properly review that question, I needed to write my own encoder and decoder to be able to test their program. Someone thought it ...
1
vote
1answer
42 views

Brute-force word cracking program using /dev/urandom

I've been having fun with this program and trying to use different methods and such to achieve the fastest possible word cracking program I can come up with. I'm pretty happy with my current program ...
2
votes
4answers
65 views

Find perfect squares between two numbers

The following problem is from codechef.com: Recently Chef become very much interested in perfect squares. We all know Chef and his weird interests. Anyways Chef will be soon writing his ...
7
votes
2answers
82 views

LZW decompressor in C (II)

Here is an update to my previous thread which you can find here. Again, I'd very much appreciate any advice or comments about the structure/logic of the program, style of the code, or reusability of ...
4
votes
1answer
57 views

vector3 math module

I'm writing a little math module in C to handle vectors and matrices. This will be column-major style but right now I've only finished the basics of the vector functions and wanted some feedback on ...
7
votes
1answer
71 views

Snake game for Windows console

I would apreciate any suggestions on how to make my code better and more efficient. ...
10
votes
1answer
411 views

LZW decompressor in C

Here is a simple decompressor in C. I'd very much appreciate any advice or comments about the structure/logic of the program, style of the code, or reusability of the features. I'm a real novice and ...
15
votes
1answer
784 views

Simple webserver in C

My first learning project in C. Looking for general feedback e.g. gotchas, coding standards, formatting, naming etc. I'm here to learn! webserver.h ...
0
votes
1answer
45 views

Remove Duplicates from Sorted List — LeetCode Solution in C

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given ...
-2
votes
0answers
12 views

In C return scanf values from function [migrated]

I am trying to write a subfunction in my calculator program to verify the operands. What I'd like the function to do is return the scanf inputs to the main() function. Here is the code I have used for ...
12
votes
1answer
71 views

Compile-time data structure generator

In response to another recent question I mentioned that one mechanism to avoid runtime overhead for creating a data structure was to create it at compile time and use it directly. Since there was ...
24
votes
5answers
1k views

Running Lights - Embedded “Hello World”

I'm getting my feet wet in embedded development, and like all those before me, my first task was to make an LED blink. I went a bit further than that and made a "runner" that lights up each led from 0 ...
7
votes
2answers
214 views

TCP Tunnel in C

I'm completely aware that I'm not using NIO, but this is my first polished C project. All criticism is welcome, if I'm doing something wrong, I want to nip it in the bud before I'm used to it. ...
14
votes
4answers
670 views

checkmate - C spelling corrector 2.0

Since I posted my first version of the spelling corrector here, I've been working on improving it a little in my free time. I've also gone ahead and put the project up on Github so that others can ...
1
vote
3answers
172 views

Confirming existence of lapindromes

The following description is taken from CodeChef.com's Lapindrome problem. Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same ...
-3
votes
1answer
26 views

Read from Serial Port in C++ is unstable [closed]

I have a serial device (RS232) from which I am requesting (binary) data. This interface answers with a sequence of 5 bytes, or 17 bytes when it has some new data. I figured out, that I have to turn ...
3
votes
2answers
60 views

Assessment of client-server program source code

Can you assess source code of my client-server program? I would like to get an advice about design, code security etc. Thank you very much. The program does the following: Show files in ...
2
votes
3answers
143 views

Reading a configuration file

I have written the following C code to parse a configuration file for settings to my program. I denote comments with a # and blank lines are allowed. e.g.: ...
2
votes
1answer
27 views

Chained hash table implementation to store student's information

This is my implementation of a Hash Table to store information about a student. Everything seems to work as expected, but I'd like some feedback on the following: Is my style good? Is it easy to ...
2
votes
1answer
103 views

Bogosort vs bogobogosort [closed]

A question on Stack Overflow had me look up the article on bogosort on Wikipedia. There they describe the bogosort algorithm and the bogobogosort algorithm. They say, about this last algorithm, that: ...
2
votes
2answers
70 views

Find all multiples of a number in given range in reverse order

I have a problem set which requires me to print all the multiples of a number in given range in reverse order. So far I have tried this but not sure it is optimized or not! ...
5
votes
1answer
68 views

Cache aware, Key/value dictionary based on 4-bit(16-slot) Trie (Prefix Tree), with deferred allocation

Deferred allocation is a memory optimizing trick of using the Node** as Node* when there is only one item in the "bucket". Thus ...
0
votes
3answers
177 views

Function to erase a character in a string

void chrrem (char arr[], size_t len, size_t pos) { memmove(arr + pos, arr + (pos + 1), (len - pos) + 1); } It is supposed to be just fast. Erases the ...
5
votes
2answers
410 views

Dijkstra Algorithm

I have implemented Dijkstra's Algorithm in C, using arrays instead of any structs. Here is my implementation: ...
7
votes
1answer
278 views

Freeing shared memory with a signal handler

I have a homework question that asks me to get 2 integers from the user, put them in shared memory, fork a child, have the child add them and put the result in shared memory, and then the child will ...
6
votes
4answers
194 views

Converting from decimal to word

I'm still investigating the problem with decimal to word conversion. I understood the basics, but now my goal is to learn how to add in base-26 (the English alphabet) or base-52 (...
5
votes
1answer
82 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 ...
7
votes
1answer
65 views

Adding support to Busybox vi for reading file from stdin

I am writing a patch for Busybox's implementation of vi, the classical command line code editor and predecessor of vim. It can ...
6
votes
3answers
121 views

Capitalised initials of username

Given a list of words, this program outputs the starting letters of the words capitalized. I was reviewing this question that solves the same task, but over time so many changes accumulated, that I ...
5
votes
2answers
137 views

Get initials from name input by user

This was an exercise from cs50. The goal was to get the initials in upper letter of a name that we got from user. So for "barack obama" we would get "BO", input like "abc" should output "A" and so on. ...
7
votes
4answers
138 views

Matrix struct with random values allocation and deallocation

I've written this code in 2013 or 2014, I think. I've rediscovered it today in one of my folders, made some changes and now I'm left (and my 2013/2014 me as well) wondering how good it looks for other ...
1
vote
3answers
51 views

Faster method for loading a hash table

I'm looking to make my code faster for loading a hash table. Any pointers would be appreciated. Below are my includes, the node def and the loading code. The dictionary loaded could be any *.txt ...
11
votes
2answers
243 views

Returning result and error status for number type conversions

Looking for review of design strategy of using a struct to return the functional result and error status. Your experience of how my design approach may succeeded ...
8
votes
3answers
248 views

Generic stack in C

I tried to implement a generic stack in C using void pointers and tried to keep it as simple as possible by delegating all responsibility to the caller of the ...
6
votes
3answers
327 views

Sample printf implementation

Here is my code for printf() implementation in C. Please share your thoughts for improvements. ...
2
votes
1answer
57 views

Efficiency of binary search and improvements

Below you can see my binary search method, and as a relatively new programmer I am looking for any suggestions on how it could be improved. ...
4
votes
3answers
42 views

Minimum number of moves for a knight

The problem is to find the minimum number of moves that a knight will take to go from one square to another on a 'n' cross 'n' chessboard. The code below is based on backtracking. It works well until ...
-2
votes
1answer
54 views

kth smallest element in min heap [closed]

I am working on to find the kth smallest element in min heap. I have code for this whose complexity is \$O(k \log k)\$. I tried to improve it to \$O(k)\$. ...
0
votes
0answers
44 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
72 views

Set-uid root program that runs a program as the user “restrict” (follow-up)

See Set-uid root program that runs a program as the user "restrict" for context. I've written a very short program that is intended to run the program specified in its arguments (...
0
votes
1answer
28 views

Set-uid root program that runs a program as the user “restrict”

I've written a very short program that is intended to run the program specified in its arguments (argv) as the user named "restrict" (which exists). I want to make ...